I have some code that retrieves a list of dealers.
I need to sort thsi list on a field that doesn't exist in the tables.
Distance from customer will be the field (I have a function for this)
I can calculate this but once I get the distance how do I resort the list in ascending order by distance
The code below displays all the dealers but not the closest one first. It is pretty random. Like I said I know how to calculate the distance but don't know how to create a new array for this data and sort it.
Not sure array_multisort is what I need
Thanks for any advice.
Here is some pseudo code that I am using
$query = tep_db_query("SELECT * FROM dealers inner join zipcode on dealers.zip = zipcode.zipcodeID WHERE " . ($crit_str) );
$totalfound = mysql_num_rows($query);
for ($i = 1; $i <= $totalfound; $i++)
{
$rs1rec = tep_db_fetch_array($query);
$INFO_DESCRIPTION .= '<b>' . $rs1rec['name'] . '</b><br>';
$INFO_DESCRIPTION .= $rs1rec['address'] . '<br>';
$INFO_DESCRIPTION .= $rs1rec['city'] .', '.$rs1rec['state'] .' '. $rs1rec['zip'] . '<br>';
$INFO_DESCRIPTION .= $rs1rec['phone'] . '<br><br>';
$INFO_DESCRIPTION .= $rs1rec['latitude'] . '<br>';
$INFO_DESCRIPTION .= $rs1rec['longitude'] . '<br><br>';
}