I am trying to work on my site and get "pagination" to work with it. I got so far as to make it loop out some of the stuff I want from my database but what I do not understand or get to work is the "next" & Previous" page. How can I in the code I did switch from page 1 to 2 and back to 1 etc.?
echo '<div id="block" border="1" width="200" style="float:center">';
$i = 0;
$perpage = 10;
$currentpage = 0;
$sql = "SELECT * FROM dogs";
$numRows = mysql_num_rows(mysql_query($sql));
$lastpage = ceil($numRows / $perpage);
$getquery = mysql_query("$sql ORDER by ID LIMIT $currentpage, $perpage");
while($rows = mysql_fetch_assoc($getquery)){
$id=$rows['id'];
echo '<a href="/index.php?dogs='. $id .'">
<img src="/dogs/'. $id .'.jpg" width="100" height="100" alt="" />
</a>';
$i++;
if($i == 10) {
echo '<br />';
echo '<br />';
$i = 0;
}
}
echo '</div>';