View Single Post
Old 12-29-2004, 02:32 PM  
Xenophage
Registered User
 
Industry Role:
Join Date: Oct 2001
Posts: 12,122
Quote:
Originally Posted by Varius
Ahh, gotcha.

Just incase though, if you are not already doing so, you can store the low-high range for the city as integer and use this formula to get the user's IP in that format for quick query speed :

$ip = $_SERVER[REMOTE_ADDR];
$ip = split("\.",$ip);
$ip = (16777216 * $ip[0]) + (65536 * $ip[1]) + (256 * $ip[2]) + $ip[3];

This (in PHP) would make $ip a nice int you can use like so:

$sql = "SELECT city_id FROM city_ip WHERE $ip > city_ip_low AND $ip < city_ip_high";

If you use a high enough version of MySQL or Oracle, you could also save the above as a stored function/procedure for maximum speed

sweet I passed it to my programmer to see if it helps out.
Xenophage is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote