Pagination, floating numbers
I wan't to do something like:开发者_JS百科
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?
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.
精彩评论