I just ran it on my own fake data table and it works fine: http://www.seasl.org/thread_PHP_10350614_2.php?page=8
However, for the bottom line to work proerly you have to correct 2 things:
if($page !=1) {
$pageprev = $page--;
should be:
if($page !=1) {
$pageprev = $page-1;
AND
if(($totalrows - ($limit * $page)) > 0) {
$pagenext = $page++;
if(($totalrows - ($limit * $page)) > 0) {
$pagenext = $page+1;
By incrementing $page the way you are, you're getting the wrong number selection at the botom.