ok, I can get them both to work, but for some reason when I add a limit to the second query the entire thing just breaks down. It gives me a fetch array error.
<?
// Connect to the database
mysql_connect ('localhost', 'login, 'pwd');
mysql_select_db ('jazon_tqhosting_com');
echo("<center>");
echo("<table border=1 cellspacing=0 cellpadding=3 bordercolor=000000 width=60%>");
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("</tr>");
$cases=array("2","3","5","8","11","18","20");
// default it to avoid errors
$from=(isset($fr)?$from:0);
// default query to 2, it avoids errors
$query=(isset($query)?$query:2);
if(!in_array($query,$cases)):
// query # wasnt in the array $cases
echo "Invalid Query number!!";
else:
// keep it without the 0 for easy matching
$passq=$query;
// add leading 0
$dep=(($query<10)?"0" . $query:$query);
$q="SELECT * FROM circular_product_list WHERE department = $dep ORDER BY product";
endif;
$total=mysql_query($q);
?>
<?
$cases=array("2","3","5","8","11","18","20");
// default it to avoid errors
$from=(isset($fr)?$from:0);
// default query to 2, it avoids errors
$query=(isset($query)?$query:2);
if(!in_array($query,$cases)):
// query # wasnt in the array $cases
echo "Invalid Query number!!";
else:
// keep it without the 0 for easy matching
$passq=$query;
// add leading 0
$dep=(($query<10)?"0" . $query:$query);
$limit="SELECT * FROM circular_product_list WHERE department = $dep ORDER BY product ASC LIMIT " . $from . ",10";
endif;
$result = mysql_query ("$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
echo("<tr bgcolor=$color>");
echo("<td>");
echo("$row[sku]");
echo("</td>");
echo("<td>");
echo("$row[product]");
echo("</td>");
echo("<td>");
echo("$row[price]");
echo("</td>");
echo("</center>");
echo("</tr>");
}
echo("</table>");
?>
<?
// 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>";
}
?>