I looked for the subject and found some questions in SO or other sites but I couldn't reach my goal.
I need a database with countries region-state and city database as in myip.ms but their price is very high for me I can't afford it.
I need the countries with country codes and regions to group them in select box. states with releated with them but states must have lat-lng şnfo to make me able to show my entries according to their states in google map. And the last one is the city as third select box.
If anybody can supply it for me I will be appraciated.
I realy tried to collect infos for this from varios sources but I stucked somewhere of the proccess.
Tkanks for your attention.
Assuming you plan on using IP addresses, you can use this API query to get location data from an IP address but don't expect 100% reliability
$data = json_decode(file_get_contents("http://api.hostip.info/get_json.php?ip=".$IP_ADDRESS),true);
$country = $data['country_code'];
// I use this to ensure different strings don't get stored for null values
if($data['country_code'] == "XX" || $data['city'] == '(Unknown city)' || $data['city'] == '(Unknown city?)') {
$city = "XX";
}
else {
$city = $data['city'];
}
You get a JSON string returned with a few things that you can use, in my case I only stored the country code but if you need more specific data, chances are you'll have to pay for it or ask the user
Hope that helps mate
Edit: for future reference this is the answer to this problem:
I've just found this one which has 6.6 million cities in the DB with country codes and should be mysql format phpro.org/index.php?route=projects/geodb