I'm trying to use Codeigniter pagination library , i want my pagination url to be like this :
mysite.com/codeigniter/controller/page/1
mysite.com/codeigniter/controller/page/2
mysite.com/codeigniter/controller/page/3
here is my controller :
class Controller extends CI_Controller {
public function index() {
$this->load->model('model');
$segment=$this->uri->segment(3);
/* Pagination */
$config['base_url']=base_url('controller/index');
$config['total_rows']=$this->model->count_active_members()->num_rows;
$config['per_page']=5;
$config['uri_segment'] = 3;
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
/* END Pagination */
$result['members']=$this->model->get_active_members($segment);
$this->load->view('view',$result);
}
}
my model :
class Model extends CI_Model {
public function get_active_members($segment) {
$this->db->select('username,email,balance,ctimes,regdate');
$this->db->limit(5,$segment);
return $this->db->get_where('members',array('status'=>'active'));
}
public function count_active_members() {
return $this->db->get_where('members',array('status'=>'active'));
}
}
it worked as i want but the problem that i have 9 rows in my db & it displays only 7