Here's code I had, but it recently stopped working It takes the zip code for the user and the user you're viewing, looks them up from the data table (z_data_zips) and does the calculation. The formula is in a handful of places - I converted mine from a MySQL example (I think, or vice versa) You can get the zip code lat/long info from the Census Bureau I believe this is where you get the file: http://www.census.gov/geo/www/gazetteer/places2k.html You want the "ZCTAs (ZIP Code Tabulation Areas): (33,233 records)" file - the schema is at the bottom of the page. Perhaps someone else might also find the error in my code below that's changed and save me the time to figure out why it no longer works :) (for all I know it could be a problem with MySQL result set too) if($visitor['uid'] > 0) { $uchk = db_query("SELECT up.country,uz.zip FROM user_profile up LEFT JOIN user_zip uz ON uz.uid=up.uid WHERE up.uid=$visitor [uid]"); if(db_numrows($uchk) == 1) { list($vc,$vz) = db_rows($uchk); $vz = intval($vz); $user_zip = intval($user_zip); $zchk1 = db_query("SELECT latitude,longitude FROM z_data_zips WHERE zip=$user_zip"); list($ulat,$ulong) = db_rows($zchk1); db_free($zchk1); $zchk2 = db_query("SELECT latitude,longitude FROM z_data_zips WHERE zip=$vz"); list($vlat,$vlong) = db_rows($zchk2); db_free($zchk2); $distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) * sin(deg2rad($vlat)) + cos(deg2rad($ulat )) * cos(deg2rad($vlat)) * cos(deg2rad($ulong - $vlong)))))); echo " <li><b>Distance from you:</b> $distance miles.</li>\n"; } db_free($uchk); } On 12/5/07, tedd <tedd@xxxxxxxxxxxx> wrote: > Hi gang: > > I'm entertaining how to determine what zip codes fall within a 50 > mile radius of another zip code. > > Anyone done this before? > > Also, does anyone have any sources for zip codes and lat/long databases? > > TIA for any help/suggestions. > > Cheers, > > tedd > -- > ------- > http://sperling.com http://ancientstones.com http://earthstones.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php