Here’s a great resource for IP geo-location, there’s a guy who’s made a MySQL table for it, so all you need to do is check the IP address against the database. I have personally been thinking of making such a site and this is going to help me do that, awesome! I hope it helps you too.
The IP addresses are listed in table ip_group_city. The data is not in the 126.96.36.199 format since it would need to be stored as text and we dont want that for obvious reasons.
Let say for ip A.B.C.D, the formula is
ip = (A*256+B)*256+C
(I assume A.B.C.0 is at the same location than A.B.C.255)
For example, if you have an ip of 188.8.131.52 (google.com)
The formula would give a result of :
ip = (74*256+125)*256+45 = 4881709
You would search for the IP address using MySQL by doing :
SELECT * FROM `ip_group_city` where `ip_start` <= 4881709 order by ip_start desc limit 1;