Using MySQL table data for controlling drop down list box
Inside the list.php file at the top there is a file include linking config.php. Keep your mysql details like connecting string and login details inside this config.php file.
Now for the second list box we have to collect all the records and load them based on the selection of first list box. (see the list.js file how the options are added ). First we will collect all the cat_id and then collect the subcategory names respective to each cat_id. Here we will be using one external while loop and one internal while loop. In the external while loop we will collect all the cat_id from second table and for each value of cat_id we will collect names of subcategory by using internal loop.
After this addition , rest all are same as list.js file.
Download the zip file with the full code and sql dump file for table creation.
This article is written by plus2net.com team.