Welcome Guest, Not a member yet? Register   Sign In
Help pagination not working
#1

[eluser]farocco[/eluser]
Hi All,

What am I doing wrong?

I am getting more pages than is necessary.

Thanks

$config['base_url'] = 'http://localhost/ci/index.php?site/query/';
$config['per_page'] = '10';

$this->db->like("Size", $this->input->post('size'));
$data['query'] = $this->db->get('shopinventory',$config['per_page'],$this->uri->segment(3));

$config['total_rows'] = $this->db->count_all_results('shopinventory');

$this->pagination->initialize($config);
$data['main_content'] = 'site/list';

$this->load->view('includes/template', $data);
#2

[eluser]mattpointblank[/eluser]
In your first DB query you're asking for all records where the 'Size' field is LIKE $_POST['size'], whereas in your second query (where you get the total_rows) you get EVERYTHING. Alter it to include the 'Size' clause as well.
#3

[eluser]farocco[/eluser]
$config['base_url'] = 'http://localhost/ci/index.php?site/query/';
$config['per_page'] = '10';

$this->db->like("Size", $this->input->post('size'),'after');
$config['total_rows'] = $this->db->count_all_results('shopinventory');
$this->pagination->initialize($config);

$this->db->like("Size", $this->input->post('size'),'after');
$data['query'] = $this->db->get('shopinventory',$config['per_page'],$this->uri->segment(3));

$data['title'] = 'National Tire Warehouse';
$data['main_content'] = 'site/list';

$this->load->view('includes/template', $data);

This seems to work until I select next page, then I get all records.
I think I am losing the post value.

Is there an eaiser way to code this?

Thanks
#4

[eluser]mattpointblank[/eluser]
Yes, you are losing the post value - you can't preserve that over pages unless you store it in a session variable once you obtain it.




Theme © iAndrew 2016 - Forum software by © MyBB