Teammuffin Posted October 12, 2011 Share Posted October 12, 2011 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 Link to comment https://forums.phpfreaks.com/topic/249001-php-and-mysql-dropdown-box-help/ Share on other sites More sharing options...
MasterACE14 Posted October 13, 2011 Share Posted October 13, 2011 PHP Dependent Drop down Link to comment https://forums.phpfreaks.com/topic/249001-php-and-mysql-dropdown-box-help/#findComment-1278834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.