PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 19th, 2000, 04:48 PM
asdf1237 asdf1237 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 6 asdf1237 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have a large database and would like to split the results into 20 per page and with arrows to go to the next page and numbers to skip pages. But I'm not sure how to do it. I know I've seen an article on how to do this somewhere, anyone know one about this?

Reply With Quote
  #2  
Old January 19th, 2000, 06:05 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
One possible way is to execute the query and use mysql_affected_rows ($retrieved=mysql_affected_rows($link)) to see how many rows were returned from it. Then use MySQL's limit in the query for each successive page.

If 144 rows were returned from the original query and this is stored in the $retrieved variable....

$increment=20;

if(empty($currval)) // this is the first query
{
$currval=0;
$query="select * from table limit $increment";
}
else // all subsequent queries
{
$currval+=20;
$query="select * from table limit $currval, $increment";
}

.
.
.
query output
.
.
.

if($currval < $retrieved)
{
print"<a href="search.php3?currval=$currval&retrieved=$retrieved">See next results</a>";
}

...limit 20 will give you the first 20 rows returned from query

...limit 20, 20 will return twenty rows starting with the 21st row

...limit 40, 20 will give 41 through 60 and so on

This is rough codestimate, but it may be able to help

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > splitting up results

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap