Use a limit in your sql query. Here is a piece of code from one of my sites (http://gagon.net) that uses the same kind of functionality that you're looking for. This script gets posts from a database, posts them, then builds a navigation bar at the bottom of the page using a "previous" and "next" link.
// Set default for begin var
if ($begin == "") {
$begin = "0";
}
// Get total number of rows in the DB and assign to afrows var
$SQL = " SELECT * FROM tablename";
mysql_db_query($db, $SQL, $cid);
$afrows = mysql_affected_rows();
// Select rows from DB to display
$SQL = " SELECT * FROM tablename";
$SQL = $SQL . " ORDER by id desc ";
$SQL = $SQL . " LIMIT $begin,5 ";
$retid = mysql_db_query($db, $SQL, $cid);
$afrows2 = mysql_affected_rows();
// Build navigation
$build_nav = "";
if ($begin != "0") {
$begin_prev = $begin - 5;
$build_nav = $build_nav . "<td align=\"left\"><a href=\"/?begin=$begin_prev\"><< Previous 5</a></td>";
}
$begin_next = $begin + 5;
if ($afrows != $begin_next && $afrows2 > 4) {
$build_nav = $build_nav . "<td align=\"right\"><a href=\"/?begin=$begin_next\">Next 5 >></a></td>";
}
// Display navigation
echo("\n<table cellspacing=\"2\" cellpadding=\"2\" border=\"0\" width=\"400\" align=\"center\">\n\t<tr>\n\t\t");
echo("$build_nav</tr></table>");
}
That isn't the entire script, just the parts that pertain to the navigation links. The importain thing is the limit in the SQL query.
Hope this helps.