I am developing on a WordPress plugin which
First: It collects lat, lng, zip, name and address of registering stores and stores in DB.
Then: Depending on current location of website's viewer it should show a list of all the stores within a given bound (say 5 km radius).
Well I got help from here http://ift.tt/1KJNlrU and based on my requirement I am using this query:
$lat = something;
$lng = something;
"SELECT id, address, name, lat, lng ( 3959 * acos(( cos( deg2rad($lat)) ) * (cos( deg2rad( lat ) )) * (cos( deg2rad( lng ) - deg2rad( $lng ) )) + ((sin( deg2rad( $lat ))) * (sin( deg2rad( lat ) ) ) )) AS distance FROM tablename HAVING distance < 100 ORDER BY distance LIMIT 0 , 20";
But it's not returning any result.
Please help
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire