473,326 Members | 2,048 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,326 software developers and data experts.

"Paging" (First/Previous/Next/Last to limit # of listings per page)

Wm
I'm trying to get a handle on the best way to handle setting up my listings
so that I display groups of about 25 records per page. I currently have a
page that returns over 1,000 names/addresses, which is obviously not very
efficient. Does anyone have any suggestions on the best way to approach
this, or recommendations on what pitfalls to avoid? I'm assuming that I need
to be able to count the total number of records that match the search
criteria, possibly at the top of the page before any HTML output, then find
some way to identify/track the first record, next record, etc...? I know I
should replace my existing query with something that limits it to about 25
records at a time, right?

Thanx in advance for any/all suggestions!
Wm

<?php include('dbconnect.php');
echo "<TABLE width=\"100%\" align=\"center\" border=\"0\"
cellpadding=\"0\" cellspacing=\"0\">";
$query="SELECT * from artists
WHERE mentor='0'
ORDER BY country DESC, state ASC, city ASC, lastname ASC";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$firstname = (ucwords(strtolower($row['firstname'])));
$lastname = (ucwords(strtolower($row['lastname'])));
$mentor= $row['mentor'];
$city= (ucwords(strtolower($row['city'])));
$state= (strtoupper($row['state']));
$country= (strtoupper($row['country']));
//....etc....
echo "
<TD align=\"left\" valign=\"top\" width=\"50%\"><FONT size=\"2\"
face=\"Arial, Helvetica, sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.
"','Artist','resizable=yes,width=750,height=400')\ ">".$firstname."
".$lastname."</A></FONT></TD>
//....etc....


Jul 16 '05 #1
2 7671
I don't know if this is an option for you, but you could try ADODB, its got
a great pager built in,

http://php.weblogs.com/ADOdb
http://phplens.com/adodb/tutorial.im....previous.html

hth

--b

"Wm" <LA*******@hotmail.com> wrote in message
news:pn**********************@news.easynews.com...
I'm trying to get a handle on the best way to handle setting up my listings so that I display groups of about 25 records per page. I currently have a
page that returns over 1,000 names/addresses, which is obviously not very
efficient. Does anyone have any suggestions on the best way to approach
this, or recommendations on what pitfalls to avoid? I'm assuming that I need to be able to count the total number of records that match the search
criteria, possibly at the top of the page before any HTML output, then find some way to identify/track the first record, next record, etc...? I know I should replace my existing query with something that limits it to about 25
records at a time, right?

Thanx in advance for any/all suggestions!
Wm

<?php include('dbconnect.php');
echo "<TABLE width=\"100%\" align=\"center\" border=\"0\"
cellpadding=\"0\" cellspacing=\"0\">";
$query="SELECT * from artists
WHERE mentor='0'
ORDER BY country DESC, state ASC, city ASC, lastname ASC";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$firstname = (ucwords(strtolower($row['firstname'])));
$lastname = (ucwords(strtolower($row['lastname'])));
$mentor= $row['mentor'];
$city= (ucwords(strtolower($row['city'])));
$state= (strtoupper($row['state']));
$country= (strtoupper($row['country']));
//....etc....
echo "
<TD align=\"left\" valign=\"top\" width=\"50%\"><FONT size=\"2\"
face=\"Arial, Helvetica, sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.
"','Artist','resizable=yes,width=750,height=400')\ ">".$firstname."
".$lastname."</A></FONT></TD>
//....etc....

Jul 16 '05 #2
"Wm" <LA*******@hotmail.com> wrote in message news:<pn**********************@news.easynews.com>. ..
I'm trying to get a handle on the best way to handle setting up my listings
so that I display groups of about 25 records per page. I currently have a
page that returns over 1,000 names/addresses, which is obviously not very
efficient. Does anyone have any suggestions on the best way to approach
this, or recommendations on what pitfalls to avoid? I'm assuming that I need
to be able to count the total number of records that match the search
criteria, possibly at the top of the page before any HTML output, then find
some way to identify/track the first record, next record, etc...? I know I
should replace my existing query with something that limits it to about 25
records at a time, right?

Thanx in advance for any/all suggestions!
Wm

<snip useless code>


You don't need any javascript to do paging. You need to use the LIMIT
clause in your sql SELECT statement in order to return a different set
of records each time. Before you do the SELECT you need to count the
records that match so you can determine the last page number. Take a
look at http://www.tonymarston.net/php-mysql...jects.html#a4d
for examples of how I handle this in an abstract database class.

Tony Marston
http://www.tonymarston.net//
Jul 16 '05 #3

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

Similar topics

1
by: Alex | last post by:
I created a page to show RealEstate Data with images retrived from the MSSQL 2000. I am using a DataGrid control: <asp:datagrid AllowPaging="True" OnPageIndexChanged="Pageindexchanged" > ...
1
by: Bruno | last post by:
Hello, I am having problem with a query, the query returns more than 6000 rows and it takes a LONG time since the sql server is not local, so I would like to use paging, but I would need to query...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
2
by: Jeff Gardner | last post by:
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...
0
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Via an ASPX (and code behind) in .net 2.0 I want to be able to "page" though and display the contents of an xml file. So if there are 100 elements, I can display "page 1 of 4" and list 25 elements...
17
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
7
by: underground | last post by:
I have a problem that I've spent countless hours on and I'm more than certain this is a obviuos issue to an expert but I am still learning. I have a paging script that I have modified to display a...
6
by: sattu | last post by:
i want to store value of querystring("id") when page postback
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.