Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. $numofpages = $totalrows / $limit;
  2.  
  3. // If the current page is higher then 5
  4. if($page > 5)
  5. {
  6.     $start = $page - 5; # start at the current page, 5 back
  7. }
  8. else
  9. {
  10.     $start = 1; # start at 1, because 5 back is a negative number
  11. }
  12.        
  13. // If page is lower then 5, we have less then 5 previous, so we want more
  14. // Nexts to equal out to 10
  15. if($start <= 5)
  16. {
  17.     $end = (10 - $start);
  18. }
  19. else
  20. {
  21.     $end = $page + 5; # End number is 5 plus our current page
  22. }
  23.        
  24. // If the end number is greater then our number of pages, we want
  25. // more previous page number to equal 10 total
  26. if($numofpages <= $end)
  27. {
  28.     $overpage = $end - $numofpages; # find out how many under 5 we have
  29.     $start = $start - $overpage; # set the new start to (page -5) - how many over
  30. }
  31. if($start <= 0)
  32. {
  33.     $start = 1;
  34. }
  35.  
  36. for($j = $start; $j <= $end && $j <= $numofpages; $j++)
  37. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement