Most solutions, I have seen, for the pagination problem query the DB twice. A first query to get the total number of rows and a second query to get the page with a LIMIT clause.
1- To get the total number of rows:
SELECT COUNT(*) as nb_rows FROM t;
2- To get the page number page_num:
SELECT field1, field2, ...., fieldn
FROM t
LIMIT page_num * itemsPerPage, itemsPerPage;
1- To get the total number of rows:
SELECT COUNT(*) as nb_rows FROM t;
2- To get the page number page_num:
SELECT field1, field2, ...., fieldn
FROM t
LIMIT page_num * itemsPerPage, itemsPerPage;