Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

World countries, state, city database

Posted on 2011-09-26
3
Medium Priority
?
926 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
[X]
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
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 111

Accepted Solution

by:
Ray Paseur earned 2000 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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 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