Okay, this is probably a lame question. I have a search page which which needs to be sorted by distance when the results come back from mysql. What's the easiest way to do this since mysql orders the results?
heres the code i wanna try to use:
function CalculateDistance($lat1, $lon1, $lat2, $lon2, $distanceType)
{
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distanceType = strtoupper($distanceType);
if ($distanceType == "K")
{
//return distance in kilometers
return ($miles * 1.609344);
}
else
{
//return distance in miles
return $miles;
}
}
Any suggestions?