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
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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.