Paginating Query Results

Pagination is a concept you’re familiar with even if you don’t know the term. When you use a search engine like Google, it displays the results as a series of pages and not as one long list. The view_users.php script could benefit from this same feature.

Paginating query results makes extensive use of the LIMIT SQL clause introduced in Chapter 4. LIMIT restricts which subset of the matched records are actually returned. To paginate the returned results of a query, each page will run the same query using different LIMIT parameters. These parameters will also be passed from page to page in the URL, like the user IDs passed from the view_users.php page.

Another, more cosmetic technique will be demonstrated here: displaying ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.