Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get states of a country when a country is selected [closed]

I have a code where it shows all countries and we can select a specific country from it. What i want now is when i select a country i want to see the list of states in that country. Can any one please help me in that ? Is there a method or API for it? Any help is appreciated. thanks

like image 830
Kiron Avatar asked Jan 20 '26 02:01

Kiron


1 Answers

Use db for getting countries and its states. Just download it.

Now use this db to query like this:

NSString *queryString = [NSString stringWithFormat:@"select zone_id , name from
                   zone where country_id = %d", countryID]; //here countryID is country code

EDIT : Get all countries with query like this:

NSString *queryStrAllCountries = [NSString stringWithFormat:@"select name from
                   countries"]; 

Get countryID from country selected with query like this:

 NSString *queryStrCountry = [NSString stringWithFormat:@"select country_id from
                   countries where name='%@'", countryName]; //provide country name selected

Refer this answer which provide information as the same.

like image 86
Paresh Navadiya Avatar answered Jan 21 '26 17:01

Paresh Navadiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!