how can i rearrange the name by the miles sorting smallest to biggest

$result = mysql_query("SELECT * FROM directory WHERE category = '$category'");


while($row = mysql_fetch_array($result))

  {
  $latd = $row['latitude'];
  $lond = $row['longitude'];
  $name = $row['name'];
  
  
  $theta = $lon - $lond; 
  $dist = sin(deg2rad($lat)) * sin(deg2rad($latd)) +  cos(deg2rad($lat)) * cos(deg2rad($latd)) * cos(deg2rad($theta)); 
  $dist = acos($dist); 
  $dist = rad2deg($dist); 
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  
        
      
  echo "$name";
  
  
 echo "<br><br>";
echo(round($miles) . "<br />");
echo "<br>";
  }

1. You put each mile in an array and each name
2. You sort the miles-array: http://php.net/manual/en/function.sort.php or an equivalent function (you can always write your own -> good for learning)
3. You run through the array echo'ing each element.

~G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.