ok, here is how i would do it - i didnt (couldnt) test it bc of our different dbs , so you may have to debug a little (maybe a parse error or 2) but i have it set to print errors for the main parts.
try this, if it isnt working ill try and figure something out
<?
// connection
mysql_connect ('localhost', 'login', 'pwd');
mysql_select_db ('jazon_tqhosting_com');
?>
<!-- table headings -->
<center>
<table border=1 cellspacing=0 cellpadding=3 bordercolor=000000 width=60%>
<tr bgcolor=#061690>
<td><font color=FFFFFF><center><b>SKU</b></center></font></td>
<td><font color=FFFFFF><center><b>Product</b><center></font></td>
<td><font color=FFFFFF><center><b>Price</b><center></font></td>
</tr>
<?
// setup defaults
$from=(isset($fr)?$fr:"0");
$query=(isset($query)?$query:"2";
// for pages at bottom
$tquery="SELECT * FROM circular_product_list";
$total=mysql_query($tquery);
// possible cases for query to =
$cases=array("2","3","5","8","11","18","20");
// main part //
if(!in_array($query,$cases)):
echo "Invalid Query number!!";
else:
// keep it without the 0 for easy matching
// add leading 0
$dep=(($query<10)?"0" . $query:$query);
$q="SELECT * FROM circular_product_list WHERE department = $dep ORDER BY product ASC LIMIT " . $from . ",10";
// used to re-pass along with page numbers
$passq=$query;
endif;
if($q)
{
// $q is set so query mysql
$r = mysql_query ($q);
//this block is php code, do not echo it
$bgcolor[0] = "#f3f3f3";
$bgcolor[1] = "#e1e1e1";
$x = 0;
$color=$bgcolor[$x];
//end php code block
if($r && mysql_num_rows($r)>0):
// theres a result so print the data out
while ($row = mysql_fetch_array($result))
{
//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
// print out data
?>
<tr bgcolor="<?=$color?>">
<td><?=$row['sku']?></td>
<td><?=$row['product']?></td>
<td><?=$row['price']?></td>
</tr>
<?
}
// print page #s out //
if(mysql_num_rows($total)>10)
{
// edit: this shoudl work better -r
$pages=floor((mysql_num_rows($total)-1)/10);
// start page table & init row //
?>
<table class=10 border=0 width="90%" align="center" cellspacing=2 cellpadding=2>
<tr>
<td width="5%">Page:</td>
<td>[<a href="?fr=0&query=<?=$passq?>">1</a>]
<?
for($i=1;$i<($pages+1);$i++)
// add in the query=$passq to make sure it hits the switch
echo "[<a href=\"?fr=" . ($i*10) . "&query=$passq\">" . ($i+1) . "</a>] ";
echo "</td></tr></table>";
}
else:
// no results present so print error
echo "No Results were found.";
endif;
}else
// query is NOT set, so print error
echo "No query was found. Please alert the webmaster!";
?>
-r