How to query by geolocation (latitude and longitude) with MySQL
In one of my posts, I explain How To Google Geocode an Address With PHP. Please refer to How To Google Geocode an Address With PHP for specifics on geocoding an address.
In this post, I’ll explain how to use those saved geocoordinates to search for properties within a distance from a specific zip code. This example assumes you have properties in a table named tbl_listings with columns for listing_zip, listing_geolatitude, and listing_geolongitude. Providing a search by zip code is very simple. Providing a search for a given distance from a specific zip code is also pretty simple if you have the geographic coordinates of the target zip code.
Continue reading “MySQL Query by Geolocation (Latitude and Longitude) Example”