473,883 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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=\"$_SESSIO N[PHP_SELF]?page=" . ($page-1) .
"&SearchString= " .urlencode($Sea rchString) . "\">&lt;&lt ; Prev</A";
}
for($i = 1 ; $i <= $NumberOfPages ; $i++) {
if($i == $page) {
$rsNav .= "<B>|$i|</B";
}else{
$rsNav .= "<A HREF=\"$_SESSIO N[PHP_SELF]?page=" . $i .
"&SearchString= " .urlencode($Sea rchString) . "\">$i</A";
}
}
if($page < $NumberOfPages) {
$rsNav .= " <A HREF=\"$_SESSIO N[PHP_SELF]?page=" . ($page+1) .
"&SearchString= " .urlencode($Sea rchString) . "\">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 2393

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=\"$_SESSIO N[PHP_SELF]?page=" . ($page-1) .
"&SearchString= " .urlencode($Sea rchString) . "\">&lt;&lt ; Prev</A";
}
for($i = 1 ; $i <= $NumberOfPages ; $i++) {
if($i == $page) {
$rsNav .= "<B>|$i|</B";
}else{
$rsNav .= "<A HREF=\"$_SESSIO N[PHP_SELF]?page=" . $i .
"&SearchString= " .urlencode($Sea rchString) . "\">$i</A";
}
}
if($page < $NumberOfPages) {
$rsNav .= " <A HREF=\"$_SESSIO N[PHP_SELF]?page=" . ($page+1) .
"&SearchString= " .urlencode($Sea rchString) . "\">Next &gt;&gt</A>";
}
echo "<BR>" . $rsNav;
</snip>
--

Regards,

Jeff Gardner
Take a look at http://phpclasses.fona nt.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=\"$_SESSIO N[PHP_SELF]?page=" . ($page-1) .
"&SearchString= " .urlencode($Sea rchString) . "\">&lt;&lt ; Prev</A";
}
for($i = 1 ; $i <= $NumberOfPages ; $i++) {
if($i == $page) {
$rsNav .= "<B>|$i|</B";
}else{
$rsNav .= "<A HREF=\"$_SESSIO N[PHP_SELF]?page=" . $i .
"&SearchString= " .urlencode($Sea rchString) . "\">$i</A";
}
}
if($page < $NumberOfPages) {
$rsNav .= " <A HREF=\"$_SESSIO N[PHP_SELF]?page=" . ($page+1) .
"&SearchString= " .urlencode($Sea rchString) . "\">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+$displayW indow ; $i++) {
if (($i 0) && ($i <=$NumberOfPage s)){

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
12651
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 variables in another class. Something like: $obj = $factory->getObject("1234");
15
2550
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 row it stops.. At least that's what I thought I did, but VC71 says "warning C4717: 'LOOP<0,1>::DO' : recursive on all control paths, function will cause runtime stack overflow". What's wrong? Here's the code: template<int M, int N>
0
4054
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 and MS Knowledge Base and found nothing helpful. This didn't seem to be acknowledged as a synchroization error. Investigations revealed data errors that resulted in a cascade of related errors. Resolving the data errors apparently cured whatever...
8
2842
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
23224
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 when I tried nesting "With" clauses in MS Access 2000 it was a no-no. Some sample code - in which it looks like they're creating/populating a ..XLS spreadsheet. "Option Explicit" is not specified in the module......
1
1981
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 be a better way. Suggestions anyone? By the way, I'm not opposed to coding, it just seems like this should be easily doable on the aspx side of things. Summary: I'm stuffing the 3 three key fields from each row in the master gridview into...
18
3656
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 abstract class that has the virtual function getId(). I then have a function that prints a special string when a bob meets another bob (all combinations of bobs has to meet and since the are schizophrenic they can also meet themselves):
0
1089
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</> </employee>
8
2767
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 addRow = table.insertRow(rowCount); addRow.id = cnt; var addCell = addRow.insertCell(1); addCell.id = cnt;
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9588
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5808
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.