View Full Version : Ajax (?) dropdown menu to pull info from MYSQL database

06-20-2009, 06:21 PM
Hi there

I'm not sure if I'm posting this in the correct section...

I need to create three dropdown boxes (box 1:colour, box 2: price, box 3:brand) and when the user presses "GO" they are returned with the correct information, pulled from corresponding fields in my MYSQL database.

For example, colour: silver, price 100-200, brand:samsung...should return 5 items on the page.

I do not need the dropdown boxes to populate depending on the previous selection - they are static, so to speak. If possible, I would also like the information to be returned on the page without the URL changing, which I think will involve ajax...?

I am not sure how to do this and appreciate any help at all, even if it is sending me to a tutorial on how to do this.

Many thanks in advance

06-20-2009, 08:45 PM
Yes, this is AJAX... However, you'll also need a server-side (e.g., PHP) script to do the actual database lookup. For example, you might use database.php?colour=silver&price=100-200&brand=samsung in the AJAX request, and database.php would be responsible for getting the information and printing it in a way that your JavaScript could understand.

As for a tutorial, there are loads, and your use case isn't all that special from a code perspective. http://www.google.com/search?hl=en&q=ajax+tutorial

06-20-2009, 09:55 PM

Thanks for your reply. I use php to pull info from my database onto my page already. My stumbling block is putting it all together for these new purposes, I can't seem to get my head around it exactly!

Does anyone have anything a bit more specific to get me started?

Many thanks

06-20-2009, 11:06 PM
Do you know how to get the values of the select elements? In case not, here are some resources:
(I would give the Mozilla Developer Center link for this, but it strangely doesn't exist (https://developer.mozilla.org/en/Gecko_DOM_Reference).)