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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.