I am building a website to learn coding and am trying to build a tool where a user clicks on a select/dropdown that contains some category names pulled from database cat and then another select will appear with subcategory names pulled from database subcat. This is almost exactly like Yelp's (go down to the categories) like Yelp's (go down to the categories).
I also made a diagram:
I already have a category dropdown that is pulling from cat database:
<p><b>Category:</b><br />
<?php
$query=SELECT id,cat FROM cat;
$result = mysql_query ($query);
echo<select name='cselect3' class='e1'><option value='0'>Please Select A Category</option>;
// printing the list box select command
while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt
echo <option value=.htmlspecialchars($catinfo['cat']).>.$catinfo['cat']. </option>;
}
echo</select>;
?>
And I have a subcat that is pulling from subcat database:
<p><b>Subcat1:</b><br />
<?php
$query=SELECT id,subcat FROM subcat;
$result = mysql_query ($query);
echo<select name='sselect1' class='e1'><option value='0'>Please Select A Category</option>;
// printing the list box select command
while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt
echo <option value=.htmlspecialchars($catinfo['subcat']).>.$catinfo['subcat'].</option>;
}
echo</select>;
?>
How do I make a subcategory dropdown based on what the user clicks on category and make it automatically appear?
Thanks so much for any and all help!