jacomus Posted March 12, 2008 Share Posted March 12, 2008 Hi, I am fairly new to PHP, and I have noticed that in my experiences I have had a tendency to re-invent the wheel.. Anyway, what I have is a series of drop down menus which have various options. The problem I have is that not all of the options in each of the drop down menus is compatible. As an example I will use a restaurant menu: Menu 1 options: Combo A, Combo B Menu 2 options: Pizza, Burger, Chicken, chicken sandwich If Combo A is chosen, then any of the options from menu 2 are available, if combo B is chosen, then Burger and Chicken Sandwich will be available as options, but not pizza. What I would like to accomplish is to have both drop-down menus on the same page, I have considered the following options: A) Having the second menu populated by information from MySQL B) Making the invalid options invisible depending on what option is currently displaying in drop down menu 1 I am not even sure if these two options are possible in PHP as I am fairly new. So if they are not possible, or if there is a much easier way of doing things, I could be saved hours of research and experimentation and would be quite grateful =) Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/ Share on other sites More sharing options...
craygo Posted March 12, 2008 Share Posted March 12, 2008 Well since php is a server side scripting language, you would have to submit the first dropdown menu to populate the second. What I would suggest is in your db have a table which holds the items and a field to hold the combo that the item can be in. in the combo field you can do something like a,b,c,d,f so when the person selects combo a from the dropdown you can then query the items with a simple query $sql = "SELECT * from tablename WHERE combo LIKE '%a%'"; Ray Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-490454 Share on other sites More sharing options...
rizla_za Posted March 12, 2008 Share Posted March 12, 2008 Hi Jacomus The fastest way is by using javascript to populate your dropdowns. Here is an example plus code. http://javascript.internet.com/forms/dropdown-box-population.html Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-490458 Share on other sites More sharing options...
craygo Posted March 12, 2008 Share Posted March 12, 2008 That is fine as long as he only has a few things to do. Who wants to type in all the drop down items. I admit Javascript works great so you don't have to submit the page but I would rather populate my drop downs from a database. Let the script do the work for you. Ray Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-490464 Share on other sites More sharing options...
jacomus Posted March 13, 2008 Author Share Posted March 13, 2008 Thanks for the info. I have been looking at both options so far and experimenting around. I need a bit more knowledge on both MySQL and Javascript to do either, so I am researching right now. Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-491519 Share on other sites More sharing options...
jacomus Posted March 13, 2008 Author Share Posted March 13, 2008 Right now I am trying to figure out how to get rid of the third box in that Javascript. Then my issue is completely solved. Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-491628 Share on other sites More sharing options...
jacomus Posted March 18, 2008 Author Share Posted March 18, 2008 Thanks for the Javascript info, I solved my problem using it. At this time I am experimenting with MySQL, I am brand new to the program but I am finding it is fairly easy to get into, so far. Link to comment https://forums.phpfreaks.com/topic/95802-drop-down-menu-direction-question/#findComment-495036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.