Hi all
I'm looking for something like find nearby attraction (ID=1) within radius of 5km and disply distance and show distance asc...
Dose anyone can help me to figure out how to do this without GIS feature.

I'm trying to figure out how to put formula inside one sql statement to get desire result out put

something like this but having problem..
Code:
SELECT a.m_name, b.m_name, round(degrees(acos(sin(radians(a.att_lat)) * sin(radians(b.att_lat)) + cos(radians(a.att_lat)) * cos(radians(b.att_lat)) * cos(radians(a.att_lon - b.att_lon)))) *60 * 1.1515) AS distance
FROM (
SELECT m_name, att_lat, att_lon
FROM attraction
WHERE ID = '1'
)a attraction b
WHERE round( degrees( acos( sin( radians( a.att_lat ) ) * sin( radians( b.att_lat ) ) + cos( radians( a.att_lat ) ) * cos( radians( b.att_lat ) ) * cos( radians( a.att_lon - b.att_lon ) ) ) ) *60 * 1.1515 ) > 5 ORDER BY distance ASC

Code:
table: attraction
+---+---------+---------+---------+
| ID | m_name | att_lat | att_lon | 
+---+---------+---------+---------+
| 1  | att_1  | 51.6528 | -0.2023 |
| 2  | att_2  | 51.5915 | -0.2283 |
| 3  | att_3  | 51.5953 | -0.1893 |
+---+---------+--------+----------+

Result out put...
+--------+---------+
| m_name | distance| 
+--------+---------+
| att_2  |    1.22 |
| att_3  |    2.51 |
| att_4  |    3.12 |
| att_5  |    4.34 |
+--------+---------+
Caluculating distance between two distance...
Code:
function distance($lat1, $lon1, $lat2, $lon2, $unit) {  
  $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; 
  $unit = strtoupper($unit); 

  if ($unit == "K") { 
    return round(($miles * 1.609344),2); 
  } else if ($unit == "N") { 
      return round(($miles * 0.8684),2); 
    } else { 
        return  round($miles,2); 
      } 
} 
echo distance(32.9697, -96.80322, 29.46786, -98.53506, "k") . " kilometers<br>"; 
?>