Explanation and References for Dynamic Dependent Select Boxes
Let me begin by saying that I did not create this example: I am a novice and I wanted to create dynamic dependent select boxes using PHP and MySQL, but I had a lot of difficulty finding satisfactory resources. The code from this page came from http://p2p.wrox.com/topic.asp?TOPIC_ID=17383. I am very aware that the code is not perfectly written, but it does give a great example and get the job done!
to make this work, you'll need to create a database in MySQL, and a user. I preloaded the script (here) to use the username "username" and the password "password", and the database "selects". If you want this to work easily, here's what you might do.
- You must have a server running, with PHP, and MySQL.
- Download the file from (here) and save it as dependent_select.php in your server directory (you'll need to change the filetype from txt to php).
- Login to the root account in MySQL and type:
- create database selects;
- create user username identified by 'username';
- grant select on selects.* to username;
- import the sql file - easiest from the command line as: mysql -u root -p (PASSWORD) < /PATH_TO/dropdown.sql
- you should be able to access and play with the script to get it working for you now...
The example page
brief explanation and references
Link to the sql file
The PHP code