In the SQL statement that I am using (reminder: )
SELECT * , 3963 *2 * ASIN(
POW( POW( SIN( (
business.lat - postcodes.lat
) /2 ) , 2 ) + ( COS( postcodes.lat ) * COS( business.lat ) * POW( SIN( (
business.lon - postcodes.lon
) /2 ) , 2 ) ) , 0.5 )
) AS D
FROM business, postcodes
WHERE postcodes.PCode = $pcode
AND 3970 *2 * ASIN(
POW( POW( SIN( (
business.lat - postcodes.lat
) /2 ) , 2 ) + ( COS( postcodes.lat ) * COS( business.lat ) * POW( SIN( (
business.lon - postcodes.lon
) /2 ) , 2 ) ) , 0.5 )
) <= $distance
ORDER BY D
LIMIT 0 , 30
How do I select the value of D (representing the distance to the item) once the query has been executed? I have tried:
$row = mysql_fetch_row($result);
$D=$row[D];
To no avail, I also need to do this to pin down why the statement doesnt return any values unless the radius distance is set to 10000 miles of so. :-S
Not to be one of those annoying *nix types that tell you to rtfm all the time but please do so every so often
http://uk.php.net/mysql_fetch_rowWhat you actually want is
http://uk.php.net/manual/en/function.mysql-fetch-assoc.phpCornet