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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s