我正在使用 Codeigniter 分页,但遇到了问题。
url 在单击时更改,如限制更新,例如 displayAllUsers/10 到 displayAllUsers/15,但结果保持不变。
这是我的控制器:
public function displayAllUsers()
{
$this->load->model('backOfficeUsersModel');
$data['loggedUser'] = $this->backOfficeUsersModel->get_by('username', $this->session->userdata('username'), FALSE,TRUE);
$this->db->order_by('userid');
$limit = 5; // this works, I have 5 records displayed on the page
$offset = 3;
$this->db->limit($limit);
$this->db->offset($offset);
$data['users'] = $this->backOfficeUsersModel->get();
// line bellow, prints correct result, 17 records total in database;
$totalresults = $this->db->get('back_office_users')->num_rows();
$this->load->library('pagination');
$config['base_url'] = site_url('/backOfficeUsers/displayAllUsers');
$config['total_rows'] = $totalresults;
$config['per_page'] = 5;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$data['main_content'] = 'users';
$data['title'] = 'Back Office Users';
$errorMessage = FALSE;
$this->load->vars($data,$errorMessage);
$this->load->view('backOffice/template');
} // end of function displayAllUsers
任何人都可以发现我做错了什么?