Solved

World countries, state, city database

Posted on 2011-09-26
3
876 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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP and Soap 3 29
Select2 jquery help 9 45
resizeing PHP image 2 22
Optimize/Performance Tune Production Databases 11 42
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now