1

I wan't to do something like:

If user is at first, second or third page then pagination numbers is: 1, 2, 3 (default, and I got this atm.).

I wan't it now, so I user is switching the page to the third page, then pagination number should look like this: 2, 3, 4 ... if user is at fourth page: 3, 4, 5 ... etc.

How can I do that in PHP?

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Lucas
  • 3,517
  • 13
  • 46
  • 75
  • Duplicate of one of the following?: http://stackoverflow.com/questions/6963766/pagination-in-php http://stackoverflow.com/questions/3927030/pagination-with-mysql-and-php-help http://stackoverflow.com/questions/3705318/simple-php-pagination Protip: use search. – Nightfirecat Oct 03 '11 at 03:16

1 Answers1

2

If you know the current page, subtract 1 from it to get the previous and add 1 to it to get the next page. Some if statements to determine if the page is <= 0 as well as > the max pages (to prevent those). If those statements are true, just add 1 to the last displayed page or subtract one from the the first displayed page.

Hope that makes senses.