Ah, I think I can see why: repeating page 1 would be my guess.
This is actually question 1 in the Newbie Forum FAQ. data submitted from a URL querystring will be in the $GET[] array. For your purposes, replace
if(empty($page)){
$page = 1;
}
with
if(empty($_GET['page'])){
$page = 1;
}
else{
$page=$_GET['page'];
}
But I should warn you that there are security holes in that large enough to drive a truck through.
if(empty($_GET['page']) || (int)$_GET['page']<1){
$page = 1;
}
else{
$page=(int)$_GET['page'];
}
And then later on you might want to check that someone hasn't tried asking for page 12352523. Figure out how many pages are possible from the count (and you should be using SELECT COUNT() instead of SELECT and counting rows), and if $page is larger than this, force it down to something sensible before using it.