Page 1 of 1

pagination script shows only 10 pages

Posted: Thu Jun 08, 2006 1:15 pm
by phpmash
hello php guys,
Presently i hvae the pagination script which shows the pages,next, previous links.
but in some cases i have around 70 pages , so it is not attractive to show all these in a page.
So i would like to get a script which shows only 10 pages,prevoius 10,previous,next 10,next links only.

Thanks

:roll:
phpmash

Posted: Thu Jun 08, 2006 9:27 pm
by tecktalkcm0391
Just do something like this:

UNTESTED:

Code: Select all

<?php 

$currentpage = 60;
$nextpage = ($currentpage+1);
$previouspage = ($currentpage-1);
$minpage = ($currentpage-11);
$maxpage = ($currentpage+11);
print('<a href="page.php?'. $previouspage .'">Previous</a>');
for($i=$minpage; $i<=$minpage; $i++){
       $minpage = ($minpage+1)
       print('<a href="page.php?'. $minpage .'">' . $minpage . '</a>');
}
for($i=$maxpage; $i<=$maxpagee; $i++){
       $maxpage = ($maxpage+1)
       print('<a href="page.php?'. $maxpage .'">' . $maxpage . '</a>');
}
print('<a href="page.php?'. $nextpage .'">Next</a>');

?>