PHP Pagination Class (PS_Pagination)

Here it is in action:

//Include the PS_Pagination class

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

//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:


#pagination, #php, #phpsense, #programming