Multiple results limited to 30 per page with PHP

Hi,

I have seen many websites whereby there are 100’s of results but they only display 30 or so per page - then there are numbered links to view more results with 30 products listed at each page. How do I do this?

I know I would use the SELECT command to get the results I want to include. But how do I code it up to only list 30 products per page, with links for each page that include 30 results on each page?

Matt.

What you’re describing is called “pagination”. There are numerous sites out there that will describe the specific implementation (Google “PHP Pagination”), but the basic theory is:

Select the total number of items.
Define the number of items per page you want.
If there is a current page number defined (usually by GET query string in the URL), page# = that value. If there is no page #, page # = 1
Query exactly that many items starting at page# - 1 * number of items (a LIMIT clause on a mysql query)
Display results.
Display page numbers (here is where the total number of items comes into play.)