You can use the formula to figure out how many zip codes are within the radius Here's a snippet of old code that did that: $radius = 50; // in miles $uchk = db_query("SELECT uz.zip FROM user_zip WHERE uid=$visitor[uid]"); if(db_numrows($uchk) == 1) { list($vz) = db_rows($uchk); $zchk = db_query("SELECT latitude,longitude FROM z_data_zips WHERE zip=$vz"); list($vlat,$vlong) = db_rows($zchk); db_free($zchk); $zips = db_query("SELECT z.zip FROM data_zips z WHERE CEIL(69*DEGREES(ACOS(SIN(RADIANS(z.latitude)) * SIN(RADIANS($vlat)) + COS(RADIANS(z.latitude)) * COS(RADIANS($vlat)) * COS(RADIANS(z.longitude - $vlong))))) < $radius"); $ziplist = ""; if(db_numrows($zips) > 0) { while(list($zip) = db_rows($zips)) { $ziplist .= "'$zip',"; } db_free($zips); $ziplist = substr($ziplist,0,strlen($ziplist)-1); $query .= " user_zips IN($ziplist)"; } } db_free($uchk); On 12/6/07, Daniel Brown <parasane@xxxxxxxxx> wrote: > On Dec 6, 2007 11:02 AM, mike <mike503@xxxxxxxxx> wrote: > [snip!] > > 1) download ZCTA (the text version) from > > http://www.census.gov/geo/www/gazetteer/places2k.html > [snip!] > > How you say? Son of the bitch. > > Well, my database still has more information, including nearby ZIP > codes, et cetera. It's about 38MB, total. > > Still.... son of the son of the son of the bitch. Great-grandson > of the bitch. > > -- > Daniel P. Brown > [Phone Numbers Go Here!] > [They're Hidden From View!] > > If at first you don't succeed, stick to what you know best so that you > can make enough money to pay someone else to do it for you. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php