I have a query that gets places based on the Haversine algorithm.
SELECT
id, description, name,
lat, `long`,
( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( `long` ) - radians($long) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance
FROM
places
HAVING
distance < 10
ORDER BY
distance
LIMIT 0, 20;
Then I echo it out in a JSON array like this:
$location = mysql_fetch_assoc($getlocations);
return print_r(json_encode($location));
However, it only returns one row when there should be at least two. Anyone know why it might be doing this? Thanks!
mysql_fetch_assocstarts at the first pointer, to get the second or so, you need to iterate.