I’m trying to do something simple, but I have a hard time with arrays for some stupid reason. I have a “whosonline” page that I want to sort by distance. The distance ($distc) is a function that computes after the sql query. The query returns the user, photo, etc.
After the query, I have this:
[php]<?
for($i=0;$i<$count;$i++) {
$userc=new User;
$photoc=new Photo;
$validatec=new Validate;
$userc->fillvars(mysql_fetch_array ($result,MYSQL_ASSOC));
$photoc->getprimaryphotobyuid($userc->uid,$db);
$distc=calculate_dist($user->uzip,$userc->uzip, $db);
if($distc=="–") $distc=“99999”;
?>
Then it fills the table with the results…etc.
<? } ?>[/php]As it is, it returns the users ordered by the sql query. I would like for it to order from closest to farthest. How do I create an array(s) to sort the results?
Right now, I have it writing a temp mySQL table and filling it with the results, including the distance, then having a new query order by distance. That’s too much and I know there’s a simpler way.
Thanks for any input!
KP