如何使分页不重置第1页的排序?因为当我订购表格时,它将在下一页重置。我该如何解决?
这是我的代码:
public function viewstudents(){
$this->pagination('students');
$studedit = $this->session->userdata('studedit_id');
if(isset($studedit)){
$this->session->unset_userdata('studedit_id');
}
$id = $this->session->userdata('id');
$userdata['user'] = $this->UsersModel->select_admin($id);
$this->load->view('include/header_admin', $userdata);
$data['students'] = $this->UsersModel->getStudents(10, $this->uri->segment(3));
$data['page'] = $this->uri->segment(3);
$msg = $this->session->userdata('msg');
if(isset($msg)){
$data['msg'] = $msg;
}
$this->load->view('admin/view_students', $data);
$this->load->view('include/footer_admin');
}
分页功能:
public function pagination($table) {
$this->load->library('pagination');
$config['base_url'] = base_url().'admin/view'.$table;
$config['per_page'] = 10;
$config['num_links'] = 3;
$config['total_rows'] = $this->db->get($table)->num_rows();
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = '<span aria-hidden="true">←</span> First';
$config['last_link'] = 'Last <span aria-hidden="true">→</span>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
}
我相信$config['base_url']
,所以我尝试将其更改为
$config['base_url'] = base_url().'admin/view'.$table.'?sortby='.$sort.'&direction='.$dir;
但是,分页在下一页中没有设置。
答案 0 :(得分:1)
我已经找到了解决方案。我做的是添加$config['reuse_query_string'] = TRUE;