How to calculate distance from lat/long in php?
What I am trying to do is I have entries in the database which have a lat/long stored with them. I want to calculate the distance between users lat/long and entries lat/long (in DB). After that, I want to echo the ones with distance less than 500 meters. So far I am able to do this using foreach . <?php mysql_connect("localhost", "beepbee_kunwarh", "kunwar") or die('MySQL Error.'); mysql_select_db("beepbee_demotest") or die('MySQL Error.'); $Lat = $_REQUEST['Lat']; $long = $_REQUEST['long']; $query = mysql_query("SELECT a.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($Lat - Lat) * pi()/180 / 2), 2) +