• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination Problem

I'm having a small problem with the pagination class.

I have 14 records in a table, and I want 6 shown at a time. Here's the code:


$config['base_url'] = base_url().'gallery/main';
$config['total_rows'] = $this->db->count_all('gallery_images');
$config['per_page'] = 6;
$config['uri_segment'] = 3;
$data['links'] = $this->pagination->create_links();

$data['results'] = $this->gallery_model->get_images($config['per_page'], $this->uri->segment(3));

Now, for some reason, the pages links echo'd in the view all have an offset the same as the per_page config var.

&nbsp;<b>1</b>&nbsp;<a href="/gallery/main/6">2</a>&nbsp;<a href="/gallery/main/12">3</a>&nbsp;<a href="/gallery/main/6">&gt;</a>&nbsp;

Shouldn't the offset be one more than the page number, for example the page 2 link goes to gallery/main/1 and not 6?


[eluser]Sarfaraz Momin[/eluser]
I think you misinterprete the offset value. Offset value in a query if the record from where the first record of the query begins so it would be always be in multiples for the number of records you want on every page and not increment it by 1 which is in some cases page value when you want to make a custom pagination for your system.

Hope it makes sense.

Have a good day !!!

Ah, I get it now. The actual offset is used in url's and not page numbers.

Thanks for that.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.