Want to populate list of all my store based on user location

How to populate my store list based on user location so that the nearest store should come first. i.e. shorted by nearest.

Asked on September 29, 2020 in PHP.
Add Comment
1 Answer(s)

Say you have your customer_lat, customer_long

SELECT latitude, longitude, SQRT(
POW(69.1 * (latitude -$customer_lat), 2) +
POW(69.1 * ($customer_long – longitude) * COS(latitude / 57.3), 2)) AS distance
FROM TableName ORDER BY distance;

Answered on September 29, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.