473,379 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

"nested" recordset paging

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
Sep 18 '06 #1
2 2369

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
Take a look at http://phpclasses.fonant.com/browse/package/3076.html

Sep 19 '06 #2
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

Sep 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Average_Joe | last post by:
Hello PHP people, Was wondering if PHP5 had some sort of "nested class" functionality. I'm trying to figure out how to return an object (with a private constructor) that has access to...
15
by: Robin Eidissen | last post by:
What I try to do is to iterate over two variables using template metaprogramming. I've specialized it such that when it reaches the end of a row ot starts on the next and when it reaches the last...
0
by: P. Emigh | last post by:
A client that synchronizes over the internet encountered Error #3003: "Could not start transaction; too many transactions already nested" when attempting to synchronize. I checked user groups...
8
by: Etienne Boucher | last post by:
Nested classes are usualy objects made to only live in their parent object instance. In other words... public class Outter { public class Inner { } }
19
by: (PeteCresswell) | last post by:
I'm going over an application written by somebody else and have encountered what looks to me like nested "With"s. Is this something new with MS Access 2003 or am I losing it? Seems to me that...
1
by: Roy | last post by:
Hey all. Below is the nested syntax on how to make a "codeless" nested gridview embedded within another gridviews templatefield column. Only problem is that it loads slow. REAL SLOW. There has to...
18
by: desktop | last post by:
I have 3 types of objects: bob1, bob2 and bob3. Each object is identified by a unique ID which gets returned by the function getId(). All bobs are descendants from class BaseBob which is an...
0
by: G.Waleed Kavalec | last post by:
The nested option for WRITING XML is pretty clear. I have a problem trying to READ nested "tables".... <employer> <acct>1234</> </employees> <employee> <lastname>Smith</> <ssn>123456789</>...
8
by: phub11 | last post by:
Hi - I have a function which appends row(s) to the bottom of a table: function mouseUpHandler() { var table = document.getElementById("mytable"); var rowCount = table.rows.length; var...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.