What part of the SQL are you having problems with? Are you using an ORDER BY clause with a LIMIT statement? If so, what are the difficulties? It's a fairly straightforward approach. Here is a mySQL example...
if (empty($starting_number)) { $starting_number=1; }
$sql = "SELECT table.id, table.name FROM table LIMIT $starting_number, 1 ORDER BY table.name";
On first instance of the page being loaded, you set $starting_number=1. That would select Andy. You would also need to know how many rows are in the table to determine the last page. Try this...
if (empty($total_rows))
{
$sql = "SELECT COUNT(table.id)";
$results = mysql_query($sql);
$total_rows = mysql_result($results, 0);
}
In your case, the total number of rows is the same as the number of pages. You can either requery the count every page (takes longer) or pass it to the next page in the anchor tag. Here's an example of the Next button anchor with the total_rows variable being passed to the next page.
if ($starting_number==$total_rows)
{
$next_row = 1; //Cycles back to page one
}
else
{
$next_row++; //Cycles to next page
}
$next_string = "<A HREF='somepage.php?starting_number=$next_row&numrows=$numrows'>";
A similar method would be applied to the previous button.
if ($starting_number==1)
{
$previous_row = $total_rows; //Cycles to the last page
}
else
{
$previous_row--; //Cycles to previous page
}
$previous_string = "<A HREF='somepage.php?starting_number=$previous_row&total_rows=$total_rows'>";
Keep in mind that if someone adds information to your database, and you don't recalc the $total_rows variable, then you'll be skipping the newly added record. If that is a potential problem, then I recommend requering the COUNT on every page.
I'm still in the midst of developing my own support site at AaronZoller.com, which should be open in the middle of June, but I use a similar method to what I described above. Once the site is open, I'll publish an article on Prev/Next button technologies cause there are a few different approaches one could use. I'll discuss them in detail there. Hope this helps in the meantime.
Aaron Zoller
www.AaronZoller.com