[RESOLVED] Dependent select boxes with PHP & MySQL
I want to do something that seems very simple but it's a bit hard to explain, so I'll just give you an example.
Suppose you have a MySQL database with 2 tables -
Cars (id, name)
Models (id, name, car_id)
The models include a reference to the car they belong to. For example, if the table "Cars" has 2 rows - (1,Mercedes) and (2,Volkswagen), then an example for a model that belongs to Mercedes in the "Models" table would be (1,E-Class,1), the latter 1 being the id of Mercedes.
My problem is this: I want to have 2 select boxes, one representing the car and the other representing the model. But, the point is that when the user changes his car selection, the other select box changes automatically so as to include only models that belong to the selected car.
I hope you understood this annoying explanation :-)
Thank you so much.
I have used your drop down menu for awhile, and it works great. However, I have encounter another problem. when I query subcategory from my database which I already selected. I cannot display the full list in the database.
Here is a picture, you see only the selected subcategory showed, but not everything on the listed. dropdown.png
Here is another picture of the full list of subcategory dropdown2.png
I wonder do you have any idea how you solve this problem?