I\'m just looking for suggestions on the best way to do this...
I need to create a search function that searches for \"users\" within a 50 mile radius of a zip code
I would first do a search for all the zipcodes in the radius of the target. Then compare all the returned zipcodes to your user table zipcodes. Pull out the matching users.
It find the zipcodes in a radius, found this MySQL call:
$query = 'SELECT zzip FROM ' . table .
' WHERE (POW((69.1*(zlongitude-"' .
$long . '")*cos(' . $long .
'/57.3)),"2")+POW((69.1*(zlatitude-"' .
$lat . '")),"2"))<(' . $radius .
'*' . $radius . ')';
MySQL does all the math for you.
I found a class that uses this here: http://www.nucleusdevelopment.com/code/do/zipcode
Hope that helps.