Please help me i don’t understand what is 3959 in this query and what is the logic of this query.
$sql = 'SELECT `Zip`, `City`, `State`, `Lat`, `Long`,
( 3959 * acos( cos( radians("%s") ) * cos( radians( `Lat` ) ) * cos( radians( `Long` ) -
radians("%s") ) + sin( radians("%s") ) * sin( radians( `Lat` ) ) ) ) AS distance
FROM Zips
HAVING distance < "%s"
ORDER BY distance LIMIT 0 , 2';
This logic is to find locations using latitudes and longitudes, Please refer to Finding Locations with MySQL
This above logic uses Haversine Formula to find location within a sphere