|
Thanks for the reply. As I'm a noob, it will take a little time to understand the code you sent. At 1st glance, it looks like I may not have been clear. I want to select only records that are less than or equal to a radius from a address that is input from a form by a user. Each record in the database contains its latitude ("lat") and longitude ("long") along with other fields (or columns). From the user input of address, and radius, I derive the variables of $lat1 and $long1 for the geocode of the user's address, and $radius for the radius. I have the code to calculate the distance (see previous post). Where I am stuck is, how to put these together to construct the proper query. I'm thinking a code similar to this:
$result = mysql_query("SELECT * , (CODE TO CALCULATE DISTANCE) as radius FROM tablename HAVING radius <= '$radius' WHERE field1 = '$var1' AND field2 > '$var2' ");
$num_rows = mysql_num_rows($result);
The (CODE TO CALCULATE DISTANCE) is where lat, long, $lat1, $long1, and $radius are used to compute the distance.
Thanks again for any help.
|