I am new to codeigniter, I am trying to create pagination on the records i am fetching from database. I have written the following code, its showing me pagination but its not effecting the result set, I still have all the records on the same page and when i click on Page2
it says no page found
.
Kindly guide me how to 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 as $teachers_records)
{
...
....
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…