Edit** Oops, jeet posted fix on next page. I didn't go far enough
I think the problem is in the while loop. You currently have:
while($row = mysql_fetch_array($q)):
$l= $row['total'];
$l=$l+$l;
endwhile;
echo $l;
You need to replace the 2nd and 3rd line to something like this:
$l = $l + $row['total'];
Your current total should end up being twice the last selected row's total. The replacement should get you the right total.