Sorry, should have made it cleared what I wanted.
I want my query to go:
$result = mysql_query("SELECT * FROM table ORDER BY $difference");
while($myrow = mysql_fetch_array($result)) {
$date1 = $myrow[date1];
$date2 = $myrow[date2];
$difference = $date1 - $date2;
}
...but obviously that query is not possible in its current form, but is there a way to get the result that I want? I want to order the query results by a result that I get from the query!