I\'ve been going through all the pagination questions and answers on the site, and among all the long-drawn out code and OO solutions, this code is among the shortest and simple
I think you have to use the OFFSET token in your query. Like so:
$query = "SELECT * FROM table ORDER BY title LIMIT $perPage OFFSET $perPage * $page";
I hope this helps.