Hey guys.
I am new to PHP and I have figured out how to populate a dropdown box with data from my database but now I want to create another dropdown box with data from my database but I want it to be data that depends on the data from the first drop down box. I am making code for a supply order for a website I am making for tafe and I filled in the first drop down box with the supplier names and now I want a second drop down box of all the products that that supplier is supplying us. I cannot for the life of me work out how to do this and I have no idea what to search to get this. Any help will be greatly appreciated. I will show you the code for my first dropdown box.
<?php
$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "ocs";
@mysql_connect("$db_host","$db_username","$db_password") or die("Could not connect to MySQL");
@mysql_select_db("$db_name") or die("Cannot find database");
$query = "SELECT ProductID FROM products";
$result = mysql_query($query) or die(mysql_error());
$dropdown = "<select name='products'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['ProductID']}'>{$row['ProductID']}</option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>
Thanks a lot
-Teammuffin