RE: [PHP] Too many records to display in one web page

From: Date: Sat, 26 May 2007 23:36:27 +0000
Subject: RE: [PHP] Too many records to display in one web page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-255693@lists.php.net to get a copy of this message
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@iteso.mx] Sent: Saturday, May 26, 2007 7:18 PM To: php-general@lists.php.net Subject: [PHP] 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

« previous php.general (#255693) next »