// Create the object and set some basic values. $pagination = new pagination(); $pagination->setMax($max);
// Get the total results, and then calculate how many pages that becomes based on how many results per page. $totSql = "SELECT * FROM `table`"; $totQuery = mysql_query($totSql) or die(mysql_error()); $totResults = mysql_fetch_array($totQuery); $totPages = $pagination->getPages($totResults);
// Set the current page, and get the first result on it. $first = $pagination->setPage($p);
I started working on an example to use this with a gallery, where the image files were in a image dir. But I got stuck.
More specificly I got stuck when I was trying to get the results within the first result on a page, and the last result on a page, based on the value of the max nr of results per page.
Maybe someone else can try to work it out?
Anyways, this is my pagination class.
Last edited by Tanax : 02-19-2009 at 11:51 PM.
The Following 3 Users Say Thank You to Tanax For This Useful Post: