计算分页中的行数并显示它


Counting rows in pagination and show it?

我在其中使用codeigniter(library) pagination类。
为什么这段代码不能为counting rows在分页工作,如:

现有行:4 ->显示9中的1到4

现有行:4 ->显示4到8

现有行:1 ->显示8到9的9

其他


$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);

此代码的输出为:of 9 |

在多个位置:

$info .= 
      ^