[SOLVED] Restricting the number of links shown
Posted: Wed Feb 21, 2007 8:40 am
I made a couple of month ago a PHP page which implements pagination: then as I do now I put the problems encountered on the forum. At that I didn' t needed to put a restriction on the links to the different pages resulted from the pagination but now I see I have to.
I' m trying to display something like
if you are on page 3: 1 2 3 4 5 6
if you are on page 5: 3 4 5 6 7 8
Here is the part of the code that outputs the links
The following code shows from the current page to the last page.
Any ideas where I screw up or any ideas for a nicer display (links ) ?
I' m trying to display something like
if you are on page 3: 1 2 3 4 5 6
if you are on page 5: 3 4 5 6 7 8
Here is the part of the code that outputs the links
Code: Select all
/*
$Current indicates the current page
$i. $j, $l the indicators for the positions
$totalN the total number of pages
*/
$j=$i+3;
$l = $Current- 2;
do
{
if($i!=$Current && $i<$j && $l<0)
{echo "<a href='categ.php?cat=" .$_GET['cat'] ."&page=" .$i ."'>" .$i."</a>";}
// displaying the first two links i.e. 3 , 4
else if ($l>0)
{
for ($t=$l; $t<$Current; $t++)
{echo "<a href='categ.php?cat=" .$_GET['cat'] ."&page=" .$l ." '>" .$i."</a>";}
}
else if ($i==$Current){echo "<b>" .$i ."</b>";}
$i=$i+1;
}
while ($i<=$totalN || $i< $j);The following code shows from the current page to the last page.
Any ideas where I screw up or any ideas for a nicer display (links ) ?