Published: 20 Jul 2016 › Updated: 20 Jul 2016

mysql SQL code for selecting nearby entries longitute latitude
$stmt = $pdodb->prepare("SELECT field1, field2, SQRT(
POW(69.1 * (dblat - :dblat), 2) +
POW(69.1 * (:dblon - dblon) * COS(dblat / 57.3), 2)) AS distance
FROM tablename HAVING distance < :distance");
$stmt->bindParam(':dblat', $lat);
$stmt->bindParam(':dblon', $lon);
$stmt->bindParam(':distance', $distance); // in miles
$stmt->execute();
Leave mysql SQL code for selecting nearby entries longitute latitude to:
Read more #mysql posts
Best Posts From sdfsdf
We have not curated any of danieleder's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.