I am filling a dropdown list and an HTML page with the contents of a MySQL database (the tablename is in the variable $tablename2). The file contains a single field, "BusinessCat", with 20 or so unique records. The code below is an attempt to display every category on an HTML document with a dropdown list at the top which would allow a user to select a category and jump to that category on the HTML page below. How do I capture what the user selected from the list before the HTML page is built? I think I am very close...
$catlist = mysql_query("SELECT * FROM " . $tablename2 . " order by BusinessCat");
echo "<select name=Category value=''>Choose a Category</option>";
while($nt = mysql_fetch_array($catlist)){
echo "<option value=$nt[BusinessCat]>$nt[BusinessCat]</option>";
}
echo "</select>";
$catlist = mysql_query("SELECT * FROM " . $tablename2 . " order by BusinessCat");
while($catrow = mysql_fetch_array($catlist)) {
// create A TARGET
echo "<a name='$catrow[BusinessCat]'></a>";
echo "<div id='CatHead'>" . $catrow['BusinessCat'] . " </div><br />" ;
echo '<form action="#top" method="get"><input type="submit" value="Back to Top" /></form>';
}
?>