OK that is what happens and here is the stripped down code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Paginator Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<?php
$weight = $_POST['weight'];
$database = "blah";
$table = "gallery";
$db = mysql_connect("*****", "***", "******") or die("couldnt connect");
mysql_select_db($database) or die("couldnt select database");
define('ROWS_PER_PAGE', 1);
if (!isset($page) || $page < 1) {
$page = 1;
}
$sql = "SELECT COUNT(*) AS Total FROM gallery WHERE year='$year'";
$resultcount = mysql_query($sql , $db) or die("Error executing $sql<br />MySQL reported: ".mysql_error());
$rowcount = mysql_fetch_row($resultcount);
$numrows = $rowcount[0];
mysql_free_result($resultcount);
$numpages = ceil($numrows / ROWS_PER_PAGE);
if ($numpages < $page) {
$page = $numpages;
}
$offset = ROWS_PER_PAGE * ($page - 1);
$query = "SELECT * FROM gallery WHERE year='$year'";
$query .= " LIMIT $offset, ".ROWS_PER_PAGE;
$result = mysql_query($query, $db) or die("Error executing $query<br />MySQL reported: ".mysql_error());
print "<table>";
while ($data = mysql_fetch_object($result)) {
print "<tr>\n";
print "<td>";
print "weight: ".$data->pounds." lb ".$data->ounces." oz";
print "<br />";
print "date caught: ".$data->date." ".$data->month." ".$data->year;
print "<br />";
print "caught by: ".$data->captor. '<br />';
print "</td>\n";
print "</tr>\n";
}
print "</table>\n";
if ($page > 1) { ?>
<a href="<?php echo $PHP_SELF; ?>?page=<?php echo $page - 1; ?>">Previous</a>
<?php }
for($i = 1; $i <= $numpages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
if ($page < $numpages) { ?>
<a href="<?php echo $PHP_SELF; ?>?page=<?php echo $page + 1; ?>">Next</a>
<?php } ?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" id="search">
<select name="year">
<option value="">Year</option>
<option value="2002">2002</option>
<option value="2003">2003</option>
<option value="2004">2004</option>
</select><br />
<input type="submit" value="search" />
</form>
</body>
</html>