To divide mySQL result sets into pages you may do the following. I assume you have made a connection to your database.
Include the Paginator class.
include("include/paginator.php");
If you are using Paginator_html include that also.
include("include/paginator_html.php");
Make a query to get the number of rows in your database. You might use somthing
like this.
$num_rows = mysql_result(mysql_query("SELECT COUNT(*) FROM your table"),0);
Make a new Paginator object
$a =& new Paginator($_GET['page'],$num_rows);
If you are using Paginator_html make a new new Paginator_html object instead of a Paginator object.
$a =& new Paginator_html($_GET['page'],$num_rows);
If using numbered links this will set the number before and behind
the current page.
$a->set_Links(3);
Get the starting point.
$limit1 = $a->getRange1();
Get the number of items displayed on page.
$limit2 = $a->getRange2();
Make your query using LIMIT
$result=mysql_query("SELECT * FROM your table LIMIT $limit1, $limit2");
Output your results in your preferred manner
If you are using Paginator alone you will need to create your links here using the methods from Paginator. See example3.php, example4.php, and the Paginator info for help in using these methods
If you are using Paginator_html you add the methods to add your links here
$a->firstLast();
Will make a set of links like this: 5 of 8 of 25 First | Prev | Next | Last |
$a->previousNext();
Will make a set of links like this: Previous 1 2 3 4 5 6 7 Next