I have a SQL query that separates the results into groups of 25:
$page = 0; // 1, 2, 3
$perPage = 25;
....
ORDER BY c.date DESC LIMIT " . ( $page * $perPage ) . ", " . $perPage);
I’m trying to figure out how I write something that loops through the number of $page returned and then echos a number back to the screen. Ie. Page 1, Page2, Page3 – based on $page.
I will assume the search PHP page is driven throught GET parameters like
pagelikea.php?page=5or something.In that case, try something of this sort:
This is just to give you a kick start. You can obviously, take this ahead in the way you would like.
What you are doing is called Pagination. Just google for
PHP Pagination, and you will end up with lots of results. And most of them are just too easy to use.Try Zend Paginator: http://framework.zend.com/manual/en/zend.paginator.html