954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php rearange issue

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 "";
echo(round($miles) . "");
echo "";
  }
narutojonin
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

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

Graphix
Posting Pro in Training
432 posts since Aug 2009
Reputation Points: 82
Solved Threads: 74
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: