Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulate another select dropdown from database based on dropdown selection
    primarykey
    data
    text
    <p>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 <strong>cat</strong> and then another select will appear with subcategory names pulled from database <strong>subcat</strong>. This is almost exactly like Yelp's (go down to the categories) <a href="http://www.yelp.com/biz_attribute?biz_id=Jsuy0DN6NhILXSkHr6UpCA" rel="noreferrer">like Yelp's (go down to the categories)</a>.</p> <p>I also made a diagram:</p> <p><img src="https://i.stack.imgur.com/2dtlp.png" alt="enter image description here"></p> <p>I already have a category dropdown that is pulling from <strong>cat</strong> database:</p> <pre><code>&lt;p&gt;&lt;b&gt;Category:&lt;/b&gt;&lt;br /&gt; &lt;?php $query="SELECT id,cat FROM cat"; $result = mysql_query ($query); echo"&lt;select name='cselect3' class='e1'&gt;&lt;option value='0'&gt;Please Select A Category&lt;/option&gt;"; // printing the list box select command while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=\"".htmlspecialchars($catinfo['cat'])."\"&gt;".$catinfo['cat']." &lt;/option&gt;"; } echo"&lt;/select&gt;"; ?&gt; </code></pre> <p>And I have a subcat that is pulling from subcat database:</p> <pre><code>&lt;p&gt;&lt;b&gt;Subcat1:&lt;/b&gt;&lt;br /&gt; &lt;?php $query="SELECT id,subcat FROM subcat"; $result = mysql_query ($query); echo"&lt;select name='sselect1' class='e1'&gt;&lt;option value='0'&gt;Please Select A Category&lt;/option&gt;"; // printing the list box select command while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=\"".htmlspecialchars($catinfo['subcat'])."\"&gt;".$catinfo['subcat']."&lt;/option&gt;"; } echo"&lt;/select&gt;"; ?&gt; </code></pre> <p>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!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload