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

#1
[eluser]Unknown[/eluser]
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:

Code:
...
$this->load->library('pagination');

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

$this->load->model('gallery_model');
$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.

Code:
&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?

Thanks.

#2
[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 !!!

#3
[eluser]Unknown[/eluser]
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.