Hello Everybody
I writing a script that will search a database and return a list of distinct category results. When the user clicks on a listed category it should return a distinct list of sub categories that fall under the first category chosen.
The categories are listing fine but when i attempt to list the sub cats it all goes south.
What am i missing?
+++++++++++++++++++++++++++++++++++
<?php
include ("connect.inc");
if ($category)
{$result = mysql_query("SELECT DISTINCT sub_cat FROM catalog WHERE category=$category",$db);
line 12 if ($myrow = mysql_fetch_array($result))
{do
{printf("<a href=\"%s?sub_cat=%s\">%s </a><br>\n", $PHP_SELF, $myrow["sub_cat"], $myrow["sub_cat"]);}
while ($myrow = mysql_fetch_array($result));
}
else
{echo "Sorry, no records were found!";}
}
else
{$result = mysql_query("SELECT DISTINCT category FROM catalog" ,$db);
if ($myrow = mysql_fetch_array($result))
{do
{printf("<a href=\"%s?category=%s\">%s </a><br>\n", $PHP_SELF, $myrow["category"], $myrow["category"]);}
while ($myrow = mysql_fetch_array($result));
}
else
{echo "Sorry, no records were found!";}
}
?>
+++++++++++++++++++++++++++++++++++
When I click the category to move to view the sub categories i get the following error.
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/home/web/wtc/view_cat.php on line 12
Sorry, no records were found!
Any insight would be greatly appreciated.
Gib