Perhaps you could store $row in an array of arrays; store only $row within
100 miles. Add another field, Distance, to each row that holds the
calculated distance.  Then, after creating the array, sort the final array
by Distance.
----- Original Message -----
From: Mike Mike <[EMAIL PROTECTED]>
Sent: Thursday, April 18, 2002 8:51 AM
Subject: [PHP] Sorting an array.

Here's what i'm working with.
I'm figuring the distance between to points based on
latitude and longitude.

while ($row = mysql_fetch_array($result))
file://calculate distance between the two cities.
$Lat2 = $row["Latitude"];
$Lon2 = $row["Longitude"];
$x = 69.1 * ($Lat2 - $Lat1);
$y = 53 * ($Lon2 - $Lon1);

$Distance = sqrt($x * $x + $y * $y);
$Distance = ceil($Distance);

       if ($Distance < 100){
echo $row["CompanyName"]."<br>";
echo $row["Address"]."<br>";
echo $row["City"]."<br>";
echo $row["State"]."<br>";
echo $row["ZipCode"]."<br>";
echo $row["PhoneNumber"]."<br>";
echo $row["FaxNumber"]."<br>";

echo "Approximant Distance = $Distance
Here is where my question comes to play.  How do I
sort the $Distance so that 4 Miles will come up first
10 second 30 third ext..
I have tried useing sort() function but it doesn't
work quite the way I want it to.
Thanks for your help

Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to