developed php website connected to mysql database , when the client make a new search the results show in a table like this

look at the colume total time in hr the result appears at the first row i want it to be in the last row for that lawyer like this

i hope any one can help me . and i will include the code i used :
$tempLawName="";
$tempsumName="";
$mysql_query1 = ("SELECT * FROM `invoice` ORDER BY lawname ASC, date ASC");
$result = mysql_query($mysql_query1) or die(mysql_error());
while($row=mysql_fetch_array($result)){
$lawname = stripslashes($row['lawyername']);
if($tempLawName!=$lawname) {
$tempLawName=$lawname; ?>
<div align="center"><font color="#000000" size="2"
face="arial"><b><?php echo $lawname ;?></b></font></div></td>
<? }
$sum1= mysql_query(" SELECT SUM(timeinhr)as totalhr FROM `invoice`");
$my_sum1=mysql_fetch_array($sum1);
?>
<td><?php
if($tempsumName!="$my_sum1[totalhr]") {
$tempsumName="$my_sum1[totalhr]";?>
<div align="center"><b><font color="#0000FF" size="2"
face="arial"><?php echo "<input type='text' name='totalhr[]' size='2' value='$my_sum1[totalhr]'>"; ?></font></b></div></td>
<? } ?>