I am trying to create pagination in my project. I have successfully created the pagination on page 1. Its showing me 8 Records on it. But when i click on Page 2, it gives the Page Not found Page.
The Url on first page is
localhost/pagination/index.php/pagination/pagination_rows
The Url on Second page shows this only,
localhost/pagination/pagination/8
I have written the following code to accomplish this.
Model
public function courses_list($limit, $start)
{
$this->db->limit($limit, $start);
$this->db->select('*');
$this->db->from('courses');
$this->db->order_by('in_semester');
$query= $this->db->get();
return $query->result();
}
Controller
public function pagination_rows() {
$config["base_url"] = base_url() . "pagination";
// $config["total_rows"] = $this->Countries_Model->record_count();
$config["total_rows"] = 100;
$config["per_page"] = 8;
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2))? $this->uri->segment(2) : 0;
$data["courses_list"] = $this->loginmodel->courses_list($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$this->load->view("courses_list", $data);
}
View
foreach ($courses_list as $courses_records)
{
$course_id= $courses_records->CourseId;
$course_name= $courses_records->CourseName;
$credit_hours= $courses_records->CreditHours;
$in_semester= $courses_records->in_semester;
....
...
..
}
<div style="text-align:center"><?php echo "Links ".$links; ?></div>