473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

City State or Country State from Database in select.....

I have a table in MYSQL database...

With Country & it's corresponding States.

Say i select US from the dropdown option it should automatically show all the states in US from a database file.

I have seen some code examples on the net which do give a solution to the above problem but you have to manually enter all the countries & their states in the code itself.(using javascript)

I want to do this by accessing database.

(1)If i select US , my code should access database & get all the states for US.
(2)If i select India, my code should access database & get all the states for India.


and so on.
Apr 6 '10 #1
1 5404
code green
1,726 Expert 1GB
You are going to need something like a `country` table with an ID
Expand|Select|Wrap|Line Numbers
  1. country_id    country
  2. 0            India
  3. 1            US
  4. 2            South Africa
  5. ...etc
Then a States table
Expand|Select|Wrap|Line Numbers
  1. states
  2. country_id    state
  3. 1          Alabama
  4. 1          Arkansas
  5. 1          California
  6. etc.......
Then you can populate the drop down boxes from a query
Apr 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: B. G. Mahesh | last post by:
hi In the registration form I have city, state, country fields. I was wondering if there was a database available on the net which has the list of states in each of the countries. That way when...
9
by: Mike McGee | last post by:
I am new to database apps, but I am making a db with access 2002. Here is what I have and what I would like for it to do. tblCustomers = holds customer info (Name, Address, City, State, Zip,...
1
by: greg.scharlemann | last post by:
Does anyone know where I could find a complete city and state database for MySQL? I've looked at the Zip Code data on the census website, but don't know the best approach to get a .dbf file into...
2
by: gk | last post by:
i want to have 2 dpendent drown box. one for country , and the other for city. if you change country in box1 , the city list will also change in box2.. How to do it in javascript ? can...
10
by: somaskarthic | last post by:
Hi In my php page , there is a user registration form. Here the user has to select the country, state, city from the drop down box. How this can be handled in php? If a country is selected in a...
5
by: jakas | last post by:
Hi In my php page , there is a user registration form. Here the user has to select the country, state, city from the drop down box. How this can be handled in php? If a country is selected in a...
1
by: adamjblakey | last post by:
Hi, At the moment i have a country and region ajax list so depending on which country you select the region field will auto fill. Now this is the code that makes this work: JS var...
6
by: dkyadav80 | last post by:
Hi sir, I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be store in xml file. when user select city then all...
11
by: pinocchio123 | last post by:
hi friends... in my php page 3 dropdownlist boxes are there.. ie country,state,city.. if country is selected, in onchange function.. corresponding states has to be populated in state...
7
by: tokcy | last post by:
Hi everyone, I need the world database of country state and city. Actually i have three drop down option in my project in 1st drop down country name should come from database and 2nd drop down...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.