开发者

Counting rows in pagination and show it?

I use of codeigniter and class (library) pagination in it.

Why this code don't work for counting rows in pagination, like:

Existing row: 4 -> Showing 1 to 4 of 9

or

Existing row:开发者_开发问答 4 -> Showing 4 to 8 of 9

or

Existing row: 1 -> Showing 8 to 9 of 9

and

other

$this->load->library('pagination');
    //$this->load->library('Jquery_pagination');
    $config['base_url'] = base_url().'admin/accommodation/show';
    $config['uri_segment'] = 4;
    $config['total_rows'] = $this->db->count_all('hotel_submits');
    $config['per_page'] = '4';
    //$config['div'] = '#num_count'; /* Here #content is the CSS selector for target DIV */
    $config['num_links'] = 10000;
    $config['full_tag_open'] = '<div id="pagination">';
    $config['full_tag_close'] = '</div>';

    $this->pagination->initialize($config);

    $offset = (int) $offset; // just to make sure nothing funky gets in here
    $data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.*
    FROM (
        SELECT *
        FROM hotel_submits
        ORDER BY id desc
        LIMIT $offset, 4    
    ) t,
    (SELECT @rownum:=0) r");

/////////////////////////////////////////////////////////////////

$curr_offset = $this->uri->segment($config['uri_segment']);
        $info = 'Showing ' . ( $curr_offset + 1 ) . ' to ' ;

        if( ( $curr_offset + $config['per_page'] ) < ( $config['total_rows'] -1 ) )
            $info = $curr_offset + $config['per_page'];
        else
            $info = $config['total_rows'];

        $info = ' of ' . $config['total_rows'] . ' | ';

        $data['num_count'] = $info;

/////////////////////////////////////////////////////////////////

$this->load->view('admin/accommodation_submit_show', $data);

The output this code is: of 9 |


In multiple places:

$info .= 
      ^
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜