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.
ListBox Validation : Checking if option is selected before submitting a form
ListBox Disable: using disabled property we can disable a listbox by radio button
Adding option: Adding options to a listbox dynamically
Moving Options Moving Options from a listbox to other
Removing Options: Removing options from a listbox
Copying List data : Copying user entered data from one to other form
Dependant list box : Linking two dropdown listboxes
list box with Data : Populating Listbox by taking data from MySQL table
Listbox Menu: Redirecting page based on selection of listbox