My english is not good so sorry for any mistake.I was trying to use codeigniter pagination library , but i am facing a problem it create extra links. My data completes in two pages but there are 4 page links appearing in the bottom when i click on 3rd or 4th link it give error. Here is my Controller code..
public function usr_list(){
$config = array();
$config["base_url"] = base_url() . "usr/usr_list";
$config["total_rows"] = $this->ListModel->record_count();
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$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>';
$config["per_page"] = 10;
$config["uri_segment"] = 3;
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = round($choice);
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["results"] = $this->ListModel->getUser($config["per_page"] , $page);
$data["links"] = $this->pagination->create_links();
$this->load->view('userList' , $data);
}
That's my Model code
function getUser($limit , $start){
$this->db->select("u_id,name,email,phone,cnic");
$this->db->from('user');
$this->db->limit($limit , $start);
$query = $this->db->get();
if($query->num_rows() > 0) {
foreach ($query->result() as $rows) {
$data[] = $rows;
}
return $data;
}
return false;
}
In the picture you can see last record is on page 2 but there are 4 links
Any suggestion?