PHP Pagination Class (PS_Pagination)

Here it is in action:

//Include the PS_Pagination class
include('ps_pagination.php');

//Connect to mysql db
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('testdb',$conn);

//Query to pass to pagination class
$sql = 'SELECT * FROM pages';

//Create a PS_Pagination object
$pager = new PS_Pagination($conn, $sql, 8, 3);

//The paginate() function returns a mysql result set for the current page
$rs = $pager->paginate();

//Loop through the result set just as you would loop
//through a normal mysql result set
while($row = mysql_fetch_assoc($rs)) {
echo $row['title'];
}//Display the navigation
echo $pager->renderFullNav();

View more and for download: http://phpsense.com/2007/php-pagination-script/

Advertisements

#pagination, #php, #phpsense, #programming