Gossamer Forum
Home : General : Perl Programming :

X number of results per page w/ MySQL

Quote Reply
X number of results per page w/ MySQL
I am working on a small MySQL search script for a clients site. I'd like to have X number of results per page. Can this be done with LIMIT somehow? What would be the most efficient way of accomplishing this?

Quote Reply
Re: X number of results per page w/ MySQL In reply to
As long as you know where to start from, yes. Pass a page number in the url, and then you can calculate an offset.
Code:
limit 0, 20 <-- first 20 records
limit 20, 20 <-- next 20 records
^ ^----- number of results
|--------- offset
Happy coding,

--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com
Quote Reply
Re: X number of results per page w/ MySQL In reply to
That wont work if every row in the table is not displayed though, will it? This is for search results so it may come up with 10 matches for every 1000 entries in the DB.

Quote Reply
Re: X number of results per page w/ MySQL In reply to
limit works on a 'select' query. It applies to the results found by the query.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin