I try to do a MySQL-query with a list of locations near me (ordered with the nearest first). I had no idea how to do that. I found this interesting post: http://funkjedi.com/technology/308-search-using-geolocation-data-in-mysql/
Everything seams clear to me. but the query doen't work. I made the following SQL-query:
SELECT *, ($distance_formula) AS distance FROM restaurants
WHERE (geolatitude BETWEEN $lat_b1 AND $lat_b2)
AND (geolongitude BETWEEN $lng_b1 AND $lng_b2)
HAVING distance < $radius ORDER BY distance ASC
The error I get is the following:
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '$distance_formula' in 'field list'
The point is, the $distance_formula is made in the script and is not a field list, that's right. But how should I do this that MySQL knows that this is to execute and it's not a field?
If you have any other help or other solution (from the green) I would be very happy. At the end, I need a solution for cakephp.
Thanks a lot
Ivo