codeigniter - how to fix codeingiter pagination and route -
i have problem whit codeignitet pagination , route!
set route function class this:
$route['admin/panel/students/new-stuedents-list/:num'] = "admin/newstuedentslist/$1";
then in controller, create function call newstuedentslist
, load pagination library, every things work fine pagination nav... :(
page loaded successfully...
, data correct...
bat when click example page 2 , page 2 loaded pagination nav show page butten ...!!!
when call page 4 form url (http:// localhost/d/index.php/admin/panel/students/new-stuedents-list/30) , again data correctly ... pagination nav show page 1 butten , number of page dont change!!!
$this->load->library('pagination'); $config['base_url'] = 'http://localhost/d/index.php/admin/panel/students/new-stuedents-list/'; $config['total_rows'] = $this->db->get('new_contest')->num_rows(); $config['pre_page'] = 10; $config['num_links'] = 20; $config['full_tag_open'] = '<div class="pagination">'; $config['full_tag_close'] = '</div>'; $this->pagination->initialize($config); $admininfo = $this->admin_model->admininfo(); $newstudentslist['students'] = $this->admin_model->newstudentslist($config['pre_page'],$this->uri->segment(5)); $data = array_merge($admininfo,$newstudentslist); $this->load->view('admin/newstudentslist',$data);
but when newstuedentslist
is:
$this->load->library('pagination'); $config['base_url'] = 'http://localhost/d/index.php/admin/newstuedentslist/'; $config['total_rows'] = $this->db->get('new_contest')->num_rows(); $config['pre_page'] = 10; $config['num_links'] = 20; $config['full_tag_open'] = '<div class="pagination">'; $config['full_tag_close'] = '</div>'; $this->pagination->initialize($config); $admininfo = $this->admin_model->admininfo(); $newstudentslist['students'] = $this->admin_model->newstudentslist($config['pre_page'],$this->uri->segment(3)); $data = array_merge($admininfo,$newstudentslist); $this->load->view('admin/newstudentslist',$data);
every thinsg work fine!
how fix problem ...? :(
you forgot 1 configuration:
$config['uri_segment'] = 5;
to determines segment of uri contains page number.
and replace pre_page
per_page
Comments
Post a Comment