Jump to content

Page Numbering Links (Range)


ted_chou12

Recommended Posts

Hello, I wish someone to check this for me:

<?php //Page Range sorting:
if ($page <= 5 && $totalpages >= 11) {$pagelowerlim = 1;$pageupperlim = 11;}
elseif ($page <= 5 && $totalpages < 11) {$pagelowerlim = 1;$pageupperlim = $totalpages;}
elseif ($page > 5 && 1 > ($totalpages - 10)) {$pagelowerlim = 1;$pageupperlim = $totalpages;}
elseif ($page > 5 && $page < ($totalpages - 4)) {$pagelowerlim = $page - 5;$pageupperlim = $page + 5;}
else {$pagelowerlim = $totalpages - 10;$pageupperlim = $totalpages;}
?>

This code is suppose to give a range of 10 with the current page the median, down by 5 and up by 5:

so the page links would look like

1 2 3 4 5 6 7 8 9 10 11

other examples:

1 2 3 4 5 6 7 8 9 10 11

if there are 15 pages:

5 6 7 8 9 10 11 12 13 14 15

 

The basic rules are:

there are always 11 numbers.

if the page is less than 6, the limit is always 11, and the min is 1.

if the page is less than 5 away from the total page number, the upper limit is the total page number, and the lower limit is 10 away from the limit.

 

Sorry to confuse you, but I had tried my best to explain it, please check for the validity, and improve it for more aligancy if possible.

Thanks,

Ted.

Link to comment
https://forums.phpfreaks.com/topic/70351-page-numbering-links-range/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.