So I’m trying to find a way to return a very large result set from a query, and display it as a paginated table on a web page.
For example, if I am trying to return 1,000 items from my database, I’d like to display them in a paginated table, 100 at a time, and only query those 100 items.
When a user enters a name to query in a search box, I’d like them to be able to click through the table paginations, where each pagination only queries for 100 items, so ‘page’ 1 displays items 1-100, ‘page’ 2 displays items 101-200, etc…
I’d like to do this because querying a very large result set and then just paginating the display is very slow.
Does anyone have any advice on how to do this using PHP and MySQL?
I have the Pagination working fine, I just can’t figure out how to run my queries.
Here is the query I have now:
mysql_query("SELECT name, age, address FROM users WHERE name='$name' AND domain_name='$age' LIMIT 100", $localDB);
How do I use this query to return only resultset 101-200, 201-300, etc…?
If you already know the quantities (numbers) for the pagination, then just put a
limiton your SQL.Example using PDO: