Page 1 of 1

Auto populated dropdown lists

Posted: Tue Jul 08, 2008 1:21 pm
by robertws1300
First allow me to sheepishly admit that my only php knowledge comes from observing dreamweaver write for me.

I wish to create a series of dropdown lists, where the entries in each list are shaded initially and become populated with data (from a mysql db) that is dependent upon the previous drop-down list selection (aside from the first 'tyear' selection, of course).

I am trying to build a site for a tireshop which would output a tire size, depending on the year, make, model, submodel of the customers car.

I am even unsure of the best format of such a database.

Thanks for any insight given!

Re: Auto populated dropdown lists

Posted: Wed Jul 09, 2008 4:00 am
by Rovas
You need to make a database which contains the tables for :1) categories of tires; 2) the tire models; 3) the manufacturer of the tires, etc. After you manually add the data into the tables then make php scripts that selects the data needed by the user.
I tried doing this once using only PHP a select box that on select would sent the selected value to the server which will build a second select containing the values for the selected category. But it was an inconvenience for the user to many callbacks to the server.
Try using AJAX and PHP: first make a PHP script that queries the database, very simple to make an example already given in thePHP manual. But instead of displayind the result in a div, you put the html tags for the select box. Second test it if it works, protect it from sql injection by using:mysql_escape_string
Third make\ copy an [http://w3schools.com/ajax/ajax_server.asp]simple AJAX script[/url] that writes into a html page the results. Link the to the PHP script and then you have your script.
If didn' t understand any of the previous copy scripts and modify for your use