You are here: Re: "nested" recordset paging « PHP Programming Language « IT news, forums, messages
Re: "nested" recordset paging

Posted by mootmail-googlegroups on 09/19/06 15:25

Jeff Gardner wrote:
> 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) . "\">&lt;&lt; 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 &gt;&gt</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

It may be slightly easier to just limit the display to the previous and
next X pages, with the current one being in the middle. In which case,
you could replace:

> for($i = 1 ; $i <= $NumberOfPages ; $i++) {

with:

$displayWindow = 3;

for($i = $page-$displayWindow ; $i <= $page+$displayWindow ; $i++) {
if (($i > 0) && ($i <=$NumberOfPages)){

If you limit the pages shown, however, be sure to include a link to go
back to page 1, and, optionally, go to the end

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация