|
Posted by Jeff Gardner on 09/18/06 21:19
Greetings:
I've a script written for paging through a given recordset with page
links, etc. I want to be able to limit the number of page numbers
displayed as a large query may result in 100 or more pages and having
100 or more page links is ugly, to say the least. Below is the code
that I am using for the paging. I'd like something like pages 1 - 5,
click 5 or next, then pages 6-10 are displayed, etc. I am not sure where
to start as far as limiting the number of pages displayed though and any
advice is appreciated.
<snip>
$rsNav="";
if($page > 1) {
$rsNav .= "<A HREF=\"$_SESSION[PHP_SELF]?page=" . ($page-1) .
"&SearchString=" .urlencode($SearchString) . "\"><< Prev</A> ";
}
for($i = 1 ; $i <= $NumberOfPages ; $i++) {
if($i == $page) {
$rsNav .= "<B>|$i|</B> ";
}else{
$rsNav .= "<A HREF=\"$_SESSION[PHP_SELF]?page=" . $i .
"&SearchString=" .urlencode($SearchString) . "\">$i</A> ";
}
}
if($page < $NumberOfPages) {
$rsNav .= " <A HREF=\"$_SESSION[PHP_SELF]?page=" . ($page+1) .
"&SearchString=" .urlencode($SearchString) . "\">Next >></A>";
}
echo "<BR>" . $rsNav;
</snip>
--
Regards,
Jeff Gardner
___________________________
"Contrary to popular belief, Unix is user friendly. It just happens
to be very selective about who its friends are." --Kyle Hearn
Navigation:
[Reply to this message]
|