Ok, I THOUGHT I had my page number stuff set up fine. Only problem now is the page numbers always default to a certain query. If you check out the page at http://www.thomasdrug.com/shop.php and click on one any item EXCEPT Over the Counter on the menu and then test out the numbers at the bottom you'll see what I'm talking about.
The code for the pages being displayed is as follows:
<table width=98% border=1 bordercolor=000000 cellspadding=0 cellspacing=0>
<tr>
<td colspan=7 bgcolor=061690>
<center><font color=ffffff><center><b>Browse by Department</b></center></font></center>
</td>
</tr>
<tr>
<td>
<center><a href="dproducts.php?query=2">Over The Counter</a>
</td>
<td>
<center><a href="dproducts.php?query=3">Beauty Aids</a>
</td>
<td>
<center><a href="dproducts.php?query=5">Household</a>
</td>
<td>
<center><a href="dproducts.php?query=8">Food and Drink</a>
</td>
<td>
<center><a href="dproducts.php?query=11">Dental Hygiene</a>
</td>
<td>
<center><a href="dproducts.php?query=18">Home Care</a>
</td>
<td>
<center><a href="dproducts.php?query=20">Vitamins</a>
</td>
</tr>
</table>
</center>
<BR><BR>
<?
// Connect to the database
mysql_connect ('localhost', 'login', 'pwd');
mysql_select_db ('thomasdrug');
echo("<center>");
echo("<table border=1 cellspacing=0 cellpadding=3 bordercolor=000000 width=98%>");
echo("<tr bgcolor=#061690>");
echo("<td>");
echo("<font color=FFFFFF><center><b>SKU</b></center></font>");
echo("</td>");
echo("<td>");
echo("<font color=FFFFFF><center><b>Product</b><center></font>");
echo("</td>");
echo("<td>");
echo("<font color=FFFFFF><center><b>Price</b><center></font>");
echo("</td>");
echo("<td>");
echo("<font color=FFFFFF><center><b>Buy Now</b><center></font>");
echo("</td>");
echo("</tr>");
$cases=array("2","3","5","8","11","18","20");
// default it to avoid errors
// default query to 2, it avoids errors
$query=(isset($query)?$query:2);
$dep=(($query<20)?"0" . $query:$query);
$limit="SELECT * FROM circular_product_list WHERE department = $dep ORDER BY product ASC LIMIT " . $from . ",20";
$limit=20; // rows to return
$numresults=mysql_query("select * from circular_product_list where department = $dep order by product");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=0;
}
$result=mysql_query("select * "."from circular_product_list where department = $dep "."order by product limit $offset,$limit");
//this block is php code, do not echo it
$bgcolor[0] = "#f3f3f3";
$bgcolor[1] = "#e1e1e1";
$x = 0;
$color=$bgcolor[$x];
//end php code block
while ($row = mysql_fetch_array($result)) {
//output a row in color
//then the next two lines change the color
$x = ($x + 1) % count($bgcolor); //php code, do not echo this
$color=$bgcolor[$x]; //php code, do not echo this
$product = ereg_replace (" ", " ", $row['product']);
echo("<tr bgcolor=$color>");
echo("<td>");
echo("<center>$row[sku]</center>");
echo("</td>");
echo("<td>");
echo("$row[product]");
echo("</td>");
echo("<td>");
echo("<center>$$row[price]</center>");
echo("</td>");
echo("<td>");
echo("<center><form target=paypal action=https://www.paypal.com/cgi-bin/webscr method=post><input type=hidden name=cmd value=_cart><input type=hidden name=business value=kennerking@simflex.com><input type=hidden name=item_name value=$product><input type=hidden name=item_number value=$row[sku]><input type=hidden name=amount value=$row[price]><input type=image src=https://www.paypal.com/images/x-click-but22.gif border=0 name=submit alt=Make payments with PayPal - it's fast, free and secure! height=23 width=87><input type=hidden name=add value=1></form></center>");
echo("</td>");
echo("</center>");
echo("</tr>");
}
echo("</table>");
print("<center>");
print("<br>");
print("<table width=98% border=1 bordercolor=000000 cellpadding=0 cellspacing=0><tr><td width=25>");
if($offset >= $limit){
$newoffset=$offset-$limit;
print " <a href=\"$PHP_SELF?offset=$newoffset\">PREV</a> ";
} else {
print " PREV ";
}
print("</td>");
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
print("<td><center>");
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> ";
}
print("</center></td><td width=25><center>");
// check to see if last page
if($numrows-$offset > $limit){
$newoffset=$offset+$limit;
print " <a href=\"$PHP_SELF?offset=$newoffset\">NEXT</a> ";
} else {
print " NEXT ";
}
print("</center></td></tr></table>");
print("</center>");
?>
Any help resolving this issue is GREATLY appreciated.