I am currently running two MySQL queries to handle my pagination ...
Query 1 selects all rows from a table, so I know how many pages I need to list.
Query 2 selects rows for the current page (for example, rows 0 to 19 (LIMIT 0, 19) for page 1, rows 20-39 for the second page, etc., etc.).
This seems to be a waste of two repeated requests, with the only difference being that it is part of the LIMIT.
What would be the best way to do this?
Should I use PHP to filter the results after running a single query?
Edit: Should I run a single query and use something like array_slice () to list only the rows that I want?
source share