php - How to create Pagination in Codeiginter? -


i new codeigniter, trying create pagination on records fetching database. have written following code, showing me pagination not effecting result set, still have records on same page , when click on page2 says no page found.

kindly guide me how create pagination?

model

public function students_list() {       $this->db->select('*');     $this->db->from('student');       $this->db->limit($limit,$start);                      $query= $this->db->get();      return $query->result();      } 

controller

public function all_students() {      //pagination                 $this->load->library('pagination');              $config['base_url'] = base_url().'mycontroller/all_students/';             $config['total_rows'] = 200;             $config['per_page'] = 5;              $this->pagination->initialize($config);              echo $this->pagination->create_links();       //pagination      $this->load->model('loginmodel');     $data['students_data']= $this->loginmodel->students_list();     $data['dropdown']=      $this->loginmodel->get_degree_names();      $this->load->view('all_students', $data);  } 

view

<?php include 'header.php'; include 'sidebar.php';   $this->pagination->create_links(); ?> <?php   foreach($students_data $teachers_records) {     ...      .... 

controller:

public function all_students()   {      $this->load->model('loginmodel');         $config['anchor_class'] = '';         $config['show_count'] = true;         $config['base_url'] = site_url('controllername/all_students');         $config['total_rows'] = sizeof($this->loginmodel->students_list());          $data['students_data']= $this->loginmodel->students_list();         $data['dropdown']=      $this->loginmodel->get_degree_names();         $config['per_page'] = 10;         $this->jquery_pagination->initialize($config);         $data['links'] = $this->jquery_pagination->create_links();         $data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;         $data['details'] = $this->loginmodel->students_list($config['per_page'], $data['page']);         $this->load->view('all_students', $data);     } 

model

public function students_list($limit=null,$start=null) {       $this->db->select('*');     $this->db->from('student');       $this->db->limit($limit,$start);                      $query= $this->db->get();      return $query->result();   } 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -