Paging Class using PHP and MySQL
Posted by Mohammad Sajjad Hossain on April 24th, 2008
Based on my last post on paging using PHP and MySQL, I have coded this class. It is very easy to implement and it will save your time. Here is a code snippet to show how simple to use it.
//include the class file include('Pager.php'); //making connection to the database mysql_connect('localhost', 'root', ''); mysql_select_db('test'); //prepare SQL $sql = 'SELECT * FROM books'; //create an object of Pager passing the SQL $pager = new Pager($sql); //set the url. this is the current page $pager->url = 'index.php'; //set number of rows. by default it is 10 $pager->rowPerPage = 5; //build the pager $pager->build(); //get paged data $rows = $pager->getPagedData();
Click the download link given below for a copy of the class. It also includes an working example.

April 24th, 2008 at 11:30 pm
[...] I have coded a class for paging, you may find it here. [...]
April 24th, 2008 at 11:42 pm
Thanks for nice work Sajjad Bhai….
I will try to implement it in my current project…
April 27th, 2008 at 1:50 pm
Everyday we need pagination.
Hope this paging class may make our life easy.