<?php
// Count the number of records which exist in the database
$count='SELECT count(*) FROM database';
$count=do_query($count);
list($count) = db_fetch_array($count);
// Devide number by the number of records to be on each page
// $amt is the amout per page
$amt=20;
// This is the amount of pages which will exist
$pages=ceil($count/$amt);
if ($_GET['page'] <= $pages && $_GET['page'] > 0)
{
$offset=$page*$amt;
}
else
{
$offset=0;
}
// Your query
$query="SELECT * FROM db LIMIT $offset, ". ($offset+$amt);
do_query($query);
for($i=0; $i < $pages; $i++)
{
$x=$i+1;
echo "<a href=" . $_SERVER['PHP_SELF'] ."?page=" . $x . ">". $x . "</a>";
}
That is example code (not working). That is a simple logic which should work. Not very cleanly code, mainly because it is a quick example to help you derive you own solution and I typed it directly into the textarea.
If you have questions or I have misunderstood the problem, tell me.