Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $numofpages = $totalrows / $limit;
- // If the current page is higher then 5
- if($page > 5)
- {
- $start = $page - 5; # start at the current page, 5 back
- }
- else
- {
- $start = 1; # start at 1, because 5 back is a negative number
- }
- // If page is lower then 5, we have less then 5 previous, so we want more
- // Nexts to equal out to 10
- if($start <= 5)
- {
- $end = (10 - $start);
- }
- else
- {
- $end = $page + 5; # End number is 5 plus our current page
- }
- // If the end number is greater then our number of pages, we want
- // more previous page number to equal 10 total
- if($numofpages <= $end)
- {
- $overpage = $end - $numofpages; # find out how many under 5 we have
- $start = $start - $overpage; # set the new start to (page -5) - how many over
- }
- if($start <= 0)
- {
- $start = 1;
- }
- for($j = $start; $j <= $end && $j <= $numofpages; $j++)
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement