title: PHP - Updating values in drop down list upon user input
body: <p>I have got 2 drop down list in my php form. Values in the drop down list would be retrieved from the database(mysql). I have got the first drop down list running. But now I need to update the 2nd drop down list upon the user's selection. The value displayed in the 2nd drop down would defer depending on the user's selection. </p>
  
  <p>How do I update values of another drop down list after a user has selected an option from the first drop down list? I have searched and seen similar question on SO but they aren't answered. Hope to get some help here. Thanks. Below is my current code I have.</p>
  
  <p>PS. If I were to create a html form, I would need to run the php script upon lauching, without any inputs to populate the first drop down list. How do I so? I'm only aware of how to send request upon inputs; E.g. <code>&lt;input type=submit&gt;</code></p>
  
  <p>.php  </p>
  
  <pre><code>&lt;?php
  $conn = mysql_connect("127.0.0.1","root","")
  mysql_select_db(MyApp,$conn);
  
  
  $sql2=("SELECT App.AppName FROM App);               
  
  
  $result2=mysql_query($sql2); 
  echo '&lt;select name="sublist"&gt;';
  echo '&lt;option value=""&gt;&lt;/option&gt;';
  
  while ($row2 = mysql_fetch_assoc($result2))
  {
      echo '&lt;option value="' . $row2['AppName'] . '"&gt;' . $row2['AppName']. '&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';                                           
  ?&gt;
  </code></pre>