jackson4 Posted June 17, 2008 Share Posted June 17, 2008 hello, i have created a script where the php connects to the database, selects the table, and inserts the the data from the table into a drop down menu. if the user selects one of the options in the drop down box, i would like the php to connect to another table in the database, perform a select query, and populate another drop down menu with those results. i have had trouble completing this second task and would appreciate any help. here is the code, the comment at end describes what i need: <?php include 'opendb.php'; ?> <html> <body> <form id="form1" name="form1" method="get" action="<?php echo $PHP_SELF; ?> "> Choose your Option :<br> <select name="select"> <option value="">-- Select --</option> <?php $query="SELECT * FROM db_table"; $list=mysql_query("select * from db_table"); while($row_list=mysql_fetch_assoc($list)){ ?> <option value="<?php echo $row_list ?>" <?php if($row_list['id']==$select){ echo "selected"; } ?>><?php echo $row_list['name']; ?></option> <?php } ?> <input type="submit" name="Submit" value="Select" > </form> </select> /*after user selects option from db_table, i would like to connect to another table in the database and create a drop down menu with the results from the second table. */ Link to comment https://forums.phpfreaks.com/topic/110632-dynamic-drop-down-menu-mysql-db/ Share on other sites More sharing options...
ratcateme Posted June 17, 2008 Share Posted June 17, 2008 that looks to me like you would have to use javascript and ajax i don't know how to do it but you could do some research but i have used the xajax class before works great if you don't want to write any javascript here is the link http://xajaxproject.org/ Scott. Link to comment https://forums.phpfreaks.com/topic/110632-dynamic-drop-down-menu-mysql-db/#findComment-567571 Share on other sites More sharing options...
craygo Posted June 17, 2008 Share Posted June 17, 2008 Use barands baaselect. Just search for his name and it is in his sig. http://members.aol.com/barryaandrew/baaselect/baaselectguide.html Ray Link to comment https://forums.phpfreaks.com/topic/110632-dynamic-drop-down-menu-mysql-db/#findComment-567576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.