Jump to content

Drop down menu direction question


jacomus

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.