i have a map page that have a forma for calculating distance but this contain 2 drop list that handle all the cities in the database to allow user to select the first point from the first drop list and the second point from the second drop list then to calculate the distance using the longitude and latitude stored in the database for each city.
village table:
- id
- village_name
- lattitude
- longiude
- district_id
i have this query untill now but i do not know if it is right
<?php
if(isset($_POST['calculate']))
{
$sql = mysql_query("SELECT ( 3959 * acos( cos( radians(37) ) * cos( radians( lattitude ) ) * cos( radians( longitude ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) )FROM village")or die(mysql_error());
}
?>
the problem is that i do not know how to calculate distance between 2 points using the latitude and longitude stored in the database
i did read about the haversine formula but i do not know how to use it here
i do not want anyone to do it for me but to explain to me and help me can anyone help me with this ????