title: How to select value from a drop-down list, get the corresponding values from another table, then put those into another drop-down list?
body: <p>Ok, here's a database.</p>
  
  <p><a href="http://i.stack.imgur.com/j05AB.png" rel="nofollow">http://i.stack.imgur.com/j05AB.png</a></p>
  
  <p>Say I've inserted values into the database for each of these tables, although the IDs would be auto incrementing. There are many BVALUES from each AVALUE, thus the AB table. I have all the AVALUEs from TABLE A in a drop-down list. A user selects an AVALUE which I put into a variable using</p>
  
  <pre><code>$AVALUE = $_POST['AVALUE']
  </code></pre>
  
  <p>Then I do an sql statement to get the AVALUEs from TABLE A that equal $AVALUE.</p>
  
  <pre><code>$sql = "SELECT AVALUE FROM TABLEA WHERE" . $AVALUE . " = AVALUE";
  </code></pre>
  
  <p>How do I then get the NAMEID from TABLEA for that AVALUE, then reference to AB where TABLEANAMEID = NAMEID from TABLEA? Then I want to get all the BVALUES by getting all the TABLEBNAMEIDs that correspond to the TABLEANAMEIDs.</p>
  
  <p>I then want those BVALUES in a drop-down list on a seperate HTML page. After a bit of Googling the solution I think would be to do some sort of a loop putting the BVALUES into a variable as all the NAMEIDs from TABLE B increment where the variable would be in an $BVALUE loop and the list values would show with all the BVALUES.</p>
  
  <p>I hope I explained that right. I think I know what I'm trying to do but I have no idea how to actually implement it. Please help guys.</p>