Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

World countries, state, city database

Posted on 2011-09-26
3
905 Views
Last Modified: 2012-05-12
I want to develop a website where user needs to enter his details like country, state, and city. where can I find such database and how can I implement that in php and mysql.

Just like http://www.datingplace.com/servlet/NewRegistration
0
Comment
Question by:sriramvemaraju2000
3 Comments
 
LVL 3

Expert Comment

by:anjos
ID: 36600279
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36600411
Anjos found a good site.  Implementation depends on the nature of the database you acquire.  If they offer the database in CSV or XML format, PHP has built in ways to process.  Then you simply create a mySQL table and you are off to the races.

If you need help with any of those steps, then please specifically ask about the specific step.  (Of note, it's foolish to help you with importing an XML file if you get a CSV file.)
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 36600480
This article shows how to translate the client's IP address to their country using the MaxMind data.  I believe that that file is free, whereas the more detailed files, giving all of country, state and city cost something.  You might want to consider a subscription, since the IP address blocks change sometimes.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_3437-IP-Address-to-Country-in-PHP.html

You might also be able to use a service like GEOIO.  Note line 10 of the code snippet.  The API key is free but rate-limited.  For a little money you can raise the rate limitations.  You can test the script on my server here.
http://www.laprbass.com/RAY_geoio_example.php

I use GEOIO to draw the map on this page.
http://www.landonbaseball.com/site_visitors.php

HTH, ~Ray
<?php // RAY_geoio_example.php
error_reporting(E_ALL);


// GET INFORMATION ABOUT YOUR SITE VISITORS LOCATION FROM GEOIO.COM
// MAN PAGE: http://www.iana.org/numbers/


// THIS IS THE URL FOR THE API
$key = ' -- GET YOUR OWN API KEY -- ';
$url = "http://api.geoio.com/q.php?key=$key&qt=geoip&d=pipe&q=";

// THIS IS THE CLIENT IP ADDRESS (ALMOST ALWAYS)
$ipa = $_SERVER["REMOTE_ADDR"];
$dat = file_get_contents($url . $ipa);
$inf = explode('|', $dat);

// SHOW WHAT WE GOT
echo "<pre>";
echo PHP_EOL . "CITY: $inf[0] ";
echo PHP_EOL . "STATE: $inf[1] ";
echo PHP_EOL . "COUNTRY: $inf[2] ";
echo PHP_EOL . "CARRIER: $inf[3] ";
echo PHP_EOL . "LAT: $inf[4] ";
echo PHP_EOL . "LON: $inf[5] ";

// SHOW A GOOGLE MAP OF WHAT WE GOT
$lnk = "<a target='_blank' href='http://maps.google.com/maps?f=q&source=s_q&hl=en&q=$inf[4],$inf[5]'>MAP: $inf[4],$inf[5]</a>";
echo PHP_EOL . $lnk;

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question