Forums
This topic is locked
Dependent HTML Select
Posted 27 Jul 2006 13:29:40
1
has voted
27 Jul 2006 13:29:40 Paul Rodger posted:
Im using PHP to connect to a sql database, and im wanting to create a dependent select option that will automatically refresh.Example user selects their country from drop down menu A, page automatically refreshes, then drop down menu b is automatically populated with the cities from the countries selected.
Any ideas, im wanting to keep everything done server side were possible.
Replies
Replied 27 Jul 2006 13:41:34
27 Jul 2006 13:41:34 Roddy Dairion replied:
you need 2 table countries and cities.
using the id from the countries table put it in the cities table e.g.
countries
id = 1
country = UK
id = 2
country = USA
id = 3
country = Africa
cities
id = 1
city = London
id = 1
citry = Wolverhampton
id = 2
city = New York
id = 3
city = Togo
etcc..
Then using a query you just select the cities according to the ID passed from the drop down menu.
using the id from the countries table put it in the cities table e.g.
countries
id = 1
country = UK
id = 2
country = USA
id = 3
country = Africa
cities
id = 1
city = London
id = 1
citry = Wolverhampton
id = 2
city = New York
id = 3
city = Togo
etcc..
Then using a query you just select the cities according to the ID passed from the drop down menu.