Have you testing on a server where register_globals turned on (I wouldn't recommend doing that, otherwise)? If not, change
PHP Code:
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//This sets the range to display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
to
PHP Code:
if(isset($_GET['pagenum']))
$pagenum =(int) $_GET['pagenum'];
else
$pagenum =0;
//This sets the range to display in our query
$max = 'limit ' .($pagenum ) * $page_rows .',' .$page_rows;
PS: When considering efficiency, using
SELECT * for fetching rows is a bad practice, and using the same for getting the total number if rows (for mysql_num_rows) is even worse. Instead of that use
Code:
SELECT count(*) as row_count ....
and then get the value of
row_count