PDA

View Full Version : Limiting # of rows returned per page...


jamescover
08-07-2004, 10:55 PM
I'm building a db in MySQL using PHP, and I need to limit the number of results per page returned in a query. Note, I don't want to limit the query, just the number of results shown per page. So, if 100 rows are returned, I want to show 20 per page, and have the others linked at the bottom, like:

Page: 1 2 3 4 5 etc.

I did a search of the forum, but only found references to the LIMIT clause. This doesn't seem to be what I need, as I don't want to limit the number of rows returned in a query, just how the results are display. So I'm not sure if this would be done with SQL, or PHP.

Any suggestions are appreciated.

Here is a link to the db so far:

http://www.ekigroup.com/dbdemo/dbdemo.php


thanks,


-james

raf
08-07-2004, 11:32 PM
what you describe is commonly known as 'recordset paging' or 'paginating'. If you run a search for it here or in the PHP forum, or on google, you'll get hundreds of links with examplecode.

All PHP-MySQL code will use a select with a limit-clause because this way, you only select the chunk of 20 records that you need. The paginationlinks will only set the 'ofset' of your limit clause.

jamescover
08-07-2004, 11:53 PM
Thanks raf! Those keywords may be all I need to come up with meaningful search results...I'll see what I can come up with...


thanks, again.


-james