Code:
<?
$limit=20;
if($page != 1){
$pageprev = $page-1;
}
echo("<a href=\"jackscategories.php?page=$pageprev\">PREV</a> "); //removed $ in front of page
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page)
echo($i." ");
else
echo("<a href=\"jackscategories.php?page=$i\">$i</a> "); //removed $ in front of page
}
if(($totalrows % $limit) != 0){
if($i == $page)
echo($i." ");
else
echo("<a href=\"jackscategories.php?page=$i\">$i</a> ");
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page+ 1;
echo("<a href=\"jackscategories.php?page=$pagenext\">NEXT</a>"); //removed +1 after page
}else
echo(" NEXT ".$limit);
mysql_free_result($result);
?>
It would only give you a division by zero error if the $limit variable is not defined. also there is a little problems with the code that i fixed. read the comments.