473,756 Members | 6,098 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 2387

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
12628
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
2534
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
4040
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
2835
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
23209
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
1971
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
3644
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
1086
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
2756
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
9454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9868
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9836
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
9707
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...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6533
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3804
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
2
3352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2664
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.