RE: Too many records to display in one web page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eduardo,
The best way to do it is on both a php and sql level. Use sql's limit
keyword in your query to return only the amount of records you want. For
instance, page 1 will have LIMIT 0, 9 in the query. Page 2 will have LIMIT
10, 19. Then you can simply use *_fetch_array and a foreach(maybe) to
iterate through all the values. If you want to have the the amount of
records dynamically generate then either have a asdf.php?min=0&max=9 or just
do min = (page * 10) - 10 and max = (page * 10) - 1. Many different ways to
do this. However I find this one to be the most efficient.

Hope this helped. 

Brian Seymour
AeroCoreProductions
http://www.aerocore.net/

-----Original Message-----
From: Eduardo Vizcarra [mailto:evizcarra@xxxxxxxx] 
Sent: Saturday, May 26, 2007 7:18 PM
To: php-general@xxxxxxxxxxxxx
Subject:  Too many records to display in one web page

Hi All

I am developing a web site that interacts with a MySQL database. When I run 
a query and display the records in a web page, this can become a problem 
because there might be too many records to be displayed in one single web 
page so I am trying to divide the total number of records and display them 
in multiple pages. Let's say, if the query returns 100 records then I would 
like to display the first 10 records and then put a navigation bar where I 
can go to the next 10 or return to the previous 10 records

Is this done at a SQL or PHP level ? any experience on doing this ?

Thanks a bunch
Eduardo 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux