Forum Moderators: coopster
I often see on php pages numbers on which you can click to see the resultset of a query from a mysql database that returns a big number of records.
I know how to create the next, previous and... links to traverse the resultset as long as there are still some records to be shown on next pages.
However, i have no idea of how i can put numbered links (1 2 3 4 5 6 7 ...) on the bottom of a page, so that when i click on the number i may be redirected to the content of that particular result set of the query.
Can someone point me to the right tutorial to do this?
Thanks
// start paging
$paging = "";
$paging .= "<td colspan='4' valign='top' align='right'>\n";
$sql1 = "select count(comm_id) as totcomm from stcomment";
$query1 = mysql_query($sql1) or die("<p>oops, couldn't get the commcount: " . mysql_error());
$tcr = mysql_fetch_array($query1);
$totcomm = $tcr['totcomm'];
$numpages = ceil($totcomm/20);
$counter = 0;
while ($counter < $numpages) {
$start = $counter * $perpage;
$pg = $counter + 1;
if ($counter + 1 == $numpages ¦¦ $start == 0 ¦¦ ($start >= $offset - 40 && $start <= $offset + 40)) {
if ($counter == $offset/$perpage) $paging .= " <b>$pg</b> ";
else $paging .= " <a href='comments.php?s=$start'>$pg</a> ";
//echo "¦ <a href='comments1.php?s=$start'>$pg</a>";
} else {
$paging .= '.';
}
$counter++;
}
$paging .= " </td>\n";
// end paging
echo $paging;