two dropdown list with mysql data

mohans
03:01:14
hi,
Actually i have a single mysql table with columns such as classname,city and more fields.
As now i want a php web page like two dropdown boxes, one for classname and another for city.
My process is first dropdown displays the classname.when i select the classname, the second dropdown shows the related cities based on classname.
When i select both the options,to display the remaining values in the table format in same page.
the main thing is i need to use only one table.
Can anyone knows pls post the source code..
it will be greatful..
smo1234
03-03-2014
Check this dd3.php script or check this tutorial on three drop down list. You need to change the query part to point to same table. After selection of 2nd drop down list you can generate the query to list out rest of the columns of the table matching the value of both 1st and 2nd list.

If you can post the structure of the table then we can write SQL part from it.
smo1234
03-15-2014
You can read this new tutorial on three linked dropdown list using Ajax.

You can download the script at http://www.plus2net.com/php_tutorial/php_drop_down-download.php
mikowei
06-03-2014
I had try the script of two dropdown list with mysql data in this page http://www.plus2net.com/php_tutorial/php_drop_down_list.php, but my second dropdown list not able to display data from database when first drop down list is select. I would like to have some advice to solve the problem. Thank You.
smo1234
06-03-2014
After selection of first list , see that your page url should change with the id in query string. If the query string is having id then your script should able to collect it and passing to second query. You can read the FAQ on dropdown list here
mikowei
06-03-2014
Thank You. Yay my url doesnt change when I click the value from the first dropdown list. I had read through FAQ on dropdown list but I still cant solve my problem. Hope to get some advice. Thankz
smo1234
06-03-2014
On selection of your first list the page is also not reloading ? Can you show us the link ? Very basic question but have you checked the JavaScript is enabled in your browser ?

Your first dropdown list box should have <select name='cat' onchange="reload(this.form)"> as the first line so onchange event of the dropdown list the JavaScript code at the top will execute to reload the page.
fate14300
01-12-2015
aw
Please Login to post your reply or start a new topic