Menu
I am trying to sort by a calculated field. I have 2 tables: lss1 and lss2. Each are the same. I am trying to get a sort order for their total number of hours.
This is what I have but no total shows and the sorting does not happen.
[code=php]$sql=”SELECT SUM(lss1.hours + lss2.hours) AS totalhours FROM lss1, lss2 WHERE lss1.lawyer=”$profname” OR lss2.lawyer=”$profname” ORDER BY totalhours desc”;
$result = mysql_query($sql) or die((“Error: “.mysql_error().$sql));
while ($rows=mysql_fetch_array($result)) {
$totalhours=$rows[‘totalhours’];
echo $totalhours;