469,950 Members | 2,171 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Place drop down menu selection into a variable to be used in an sql query

Hi There,

I am a bit of a newbie to PHP programming and I would like to know how I can place a selected drop down option into a PHP variable and then produce an sql query which incorporates this variable.

I have created a dynamic drop down menu that populates itself with data from a MySQL table. I now want it to populate a second drop-down menu with relevant options from my database, based upon a query using a variable.

For example.....

I.e. drop-down one options = Fruit

The user selects Fruit.

drop-down two options = Apple

In this way, only options relevant to the first drop-down selection are shown in the second drop-down.

Can you help, please.


Mar 17 '07 #1
2 2894
1,584 Expert 1GB
The best way to do this PHP/AJAX. As you mentioned in your post you have already completed the first List menu. So for the onchange event of those list items, you have to call for a JS function, to submit the Values to the server side script.
from there generate the Next List menu and Print it back in the same page.

Other way is using a $PHP_SELF action form.
Don't ask to submit the coding for these stuffs. start it by your self and if error occurs come back to the thread with your Codings. :)
Mar 17 '07 #2
Hello not sure about PHP but for javascript you can just use the onchange and then put this.value and then call a function to save the value
Mar 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Jim Bo | last post: by
6 posts views Thread by Greg Scharlemann | last post: by
1 post views Thread by Greg Scharlemann | last post: by
3 posts views Thread by scaredemz | last post: by
8 posts views Thread by barbarowa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.