Author Topic: Postcode Radius Search thingy  (Read 2239 times)

  • Offline cornet

  • Posts: 143
  • Full Member
Postcode Radius Search thingy
Reply #15 on: July 16, 2006, 23:35:00 PM
You want
Code: [Select]

$res_count = mysql_num_rows($result);


mysql_numrows() is part of the MySQL Improved Extension library.

Cornet

Postcode Radius Search thingy
Reply #16 on: July 17, 2006, 10:40:18 AM
Lol, mysql_num_rows was the only part I was sure of!

Thanks for the ongoing help. Its very much appriciated.
Formerly sexytw

Postcode Radius Search thingy
Reply #17 on: July 17, 2006, 20:19:47 PM
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

Formerly sexytw

  • Offline cornet

  • Posts: 143
  • Full Member
Postcode Radius Search thingy
Reply #18 on: July 17, 2006, 20:54:51 PM
Quote from: sexytw
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_row

What you actually want is
http://uk.php.net/manual/en/function.mysql-fetch-assoc.php

Cornet


0 Members and 1 Guest are viewing this topic.