Fetch the latitude and longitude of user postal code by using this url example:
http://maps.googleapis.com/maps/api/geocode/json?address=canada&components=postal_code:<user_postalcode>&sensor=false
Then fetch the result using the below query
SELECT Shop, latitude, longitude, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng ) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance ,latitude,longitude FROM <YOUR TABLE> ORDER BY distance ASC ;
I didnt check it well. But i think it will helps your problem.
1
solved fetch the result based on the user postalcode [closed]