• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the pagination class


I have the following bunch of code (check attached file) inside one of my controllers. In a nutshell this function is to show the messages of one user. It utilizes URI helper to take the username and calls the pagination class to split the message into several pages.

But I have a problem with the pagination links Sad

I can't find the bug in my code.

Anybody's help will be more that welcome.


what is the problem? Can you be more specific?

ok. via the controller that I 've sent, a view is loaded which has this sample code

<?php echo $results; ?>
<?php echo $this->pagination->create_links(); ?>

and the produced HTML page has inappropriate links for the pagination. To be more specific the line echo $this->pagination->create_links() produce this html code


<a href="http://localhost/friendy/index.php/user/profile/chzigkol/5">2</a>&nbsp;

<a href="http://localhost/friendy/index.php/user/profile/chzigkol/10">3</a>&nbsp;

<a href="http://localhost/friendy/index.php/user/profile/chzigkol/5">&gt;</a>&nbsp;

take a look at the first and last line. There are errors in there. The last link should be ended with the number 15, not with 5.

I attached the two files, the view and the HTML. Maybe someone can find the problem

Thanks anyway


the last item is the 'next' link surely - it just moves you on to the next page, not the last page.

to me it looks like it's working properly!

yeah you are right about the last link. it's the NEXT. However it is not working properly.

When i click on the links for the 2nd page (2) and for the 3rd page (3), the link for the first page (1) is not activated. It should have been activated anyway if I am not mistaken.

And there is no previous button when I am on the 2 or 3 page.

I was wondering if the two uri segments ($username and $offset) cause that problem to the pagination class.


yep! sounds like CI hasn't guessed correctly which URI segment contains the pagination, so you can tell it:

$config['uri_segment'] = 4;
(I think your pagingation number is in uri segment 4?

yep! that was the error.

thanks a lot for your time.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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