Im looking for a database with latitude and longitude locations. I want to get all locations in a specific radius.
Then I encode the returned results in JSON and retrieve the data using ajax, however I get an undefined error meaning there is no data returned from the database.
Can anyone see where I'm wrong?
Here is my request
$sql="SELECT *, ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `lat` ) ) * COS( RADIANS( $fLat )) * COS( RADIANS( `lng` ) - RADIANS( $fLon )) ) * 6380 AS `distance` FROM `markers` WHERE ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `lat` ) ) * COS( RADIANS( $fLat )) * COS( RADIANS( `lng` ) - RADIANS( $fLon )) ) * 6380 < 10 ORDER BY `distance`"; $result = mysql_query($sql); while($r = mysql_fetch_assoc($result)) $rows[] = $r; echo json_encode($rows);
source share