Skip to content

Instantly share code, notes, and snippets.

@onocom
Created May 7, 2016 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onocom/8dd313f86ae99eb75fd1637b74512aaf to your computer and use it in GitHub Desktop.
Save onocom/8dd313f86ae99eb75fd1637b74512aaf to your computer and use it in GitHub Desktop.
//https://developers.google.com/maps/articles/phpsqlsearch_v3#outputting-xml-with-php
// Search the rows in the markers table
$query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_lat),
mysql_real_escape_string($center_lng),
mysql_real_escape_string($center_lat),
mysql_real_escape_string($radius));
$result = mysql_query($query);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment