Welcome Guest, Not a member yet? Register   Sign In
undefined table data, pagination related

I'm trying to get users only with gender M, however pagination is trying to get all the values, therefore when the value is not equal it gives me this error, other wise everything is working perfectly fine

could someone give me advice how to solve this problem?

my model
function list_all(){
  return $this->db->get($tbl_person);

function count_all(){
  return $this->db->count_all($this->tbl_person);

function get_paged_list($gender,$limit = 10, $offset = 0){
  return $this->db->get_where($this->tbl_person,array("gender" => $gender), $limit, $offset);

my controller
$puslapiai = $this->Puslapiai_model->get_paged_list('M', $this->limit, $offset)->result();
  // generate pagination
  $config['base_url'] = site_url('puslapiai/index/');
   $config['total_rows'] = $this->Puslapiai_model->count_all();
   $config['per_page'] = $this->limit;
  $config['uri_segment'] = $uri_segment;
  $data['pagination'] = $this->pagination->create_links();
  // generate table data


If you are using a where in your query to get the results, you need to use the same where when you are getting the count.

lets say you had 50 males and 50 females.
If you query to get males, you get 50, but your count function is still returning 100 because you don't have the same where (only males) in it.

function count_all($gender){
     $query = $this->db->get_where($this->edit_pages, array("gender" => $gender));
     return  $count = $query->num_rows();
seems to work

thanks for solution

Theme © iAndrew 2016 - Forum software by © MyBB