我有 codeigniter 应用程序,它的分页代码就像一个魅力。分页允许访问者选择他希望每页看到多少记录。现在,我想添加以下内容:
从总共 Z 条记录中显示 X 到 Y。
现在,Z 很容易……我已经解决了。谁能告诉我我怎么能做到这一点?
这是我拥有的功能:
public function displayAllUsers()
{
if ($this->uri->segment(3) !="") {
$limit = $this->uri->segment(3);
} else {
$limit = 10;
}
$offset = 4;
$offset = $this->uri->segment(4);
$this->db->limit($limit, $offset);
$data['users'] = $this->backOfficeUsersModel->get();
$totalresults = $this->db->get('back_office_users')->num_rows();
$this->session->set_userdata('totalresults', $totalresults);
//initializing & configuring paging
$this->load->library('pagination');
$config['base_url'] = site_url('/backOfficeUsers/displayAllUsers/'.$limit.'/');
$config['total_rows'] = $totalresults;
$config['per_page'] = $limit;
$config['uri_segment'] = 4;
$config['full_tag_open'] = '<div class="dataTables_paginate paging_bootstrap pagination"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['cur_tag_open'] = '<li><a href=# style="color:#ffffff; background-color:#258BB5;">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
//....irelevant content.....
} // end of function displayAllUsers
任何帮助将不胜感激。