Forum Moderators: coopster
I am using the script by Micah Carrick.
I could get it working with the zipcodes printed within a certain range. But am unable to provide the functionality for range from closest to furthest.
The distance is obviously not stored in database.
Any ideas/help?
echo " Print the nearest locations <br>";
foreach ($zips as $key => $value) {
$sql = "SELECT loc_name, zip_code_loc , state_prefix from locations WHERE zip_code_loc = $key order by zip_code_loc";
$sql = mysql_query($sql);
$miles = $z->get_distance( $zipcode, $key);
while ($row1 = mysql_fetch_array($sql)) { //2
echo "Zipcode : {$row1['zip_code_loc']} <br>";
echo "Printing the miles ";
echo "$miles <br>";
} //2
I was doing with "order by" zipcodes where the locations are.
But the result shows -
Results
Zipcode : 70062
Printing the miles 2.99
Zipcode : 70062
Printing the miles 2.99
Zipcode : 70094
Printing the miles 2.09
Zipcode : 70121
Printing the miles 2.98
[/code]
My problem, I want 70094 with miles 2.09 to be printed at first, followed by 70121 with 2.98 miles and so on ....