Please note: this database: In our recent tests, the GeoIP databases tested at 99.8% accurate on a country level, 90% accurate on a state level in the US, and 83% accurate for cities in the US within a 40 kilometer radius.
I would look something like PEAR GeoLite library
A quick snippet of using this library in php:
$geoip = Net_GeoIP::getInstance(dirname(__FILE__) . '/data/GeoLiteCity.dat'); $ipaddress = '72.30.2.43'; // Yahoo! $location = $geoip->lookupLocation($ipaddress); var_dump($location);
The result will be displayed, something similar:
object(Net_GeoIP_Location)[2] protected 'aData' => array 'countryCode' => string 'US' (length=2) 'countryCode3' => string 'USA' (length=3) 'countryName' => string 'United States' (length=13) 'region' => string 'CA' (length=2) 'city' => string 'Sunnyvale' (length=9) 'postalCode' => string '94089' (length=5) 'latitude' => float 37.4249 'longitude' => float -122.0074 'areaCode' => int 408 'dmaCode' => float 807
source share