faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

76 of 81 people (94%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How can I return a limited number of the rows found?
How can I show only n (eg: 10) results per page?

Jul 4th, 1999 04:25
Nathan Wallace,


In MySQL you can use Limit and offset to show a subset of the query
results.  This is great for implementing search engine style result
listings with links to the next and previous results.

For Example:

    $query="select * from table LIMIT $offset,10";

The first time $offset should be 0 (first 10 results).

After that $offset should be incremented as $offset + 10.

    http://www.mysql.com/Manual_chapter/manual_Reference.html#SELECT