Page 1 of 1

A simple "totalling" query to produce - can't get it right.

Posted: Mon Dec 08, 2008 5:34 am
by simonmlewis
I am echoing a table of values, the one in question is $row->total.

There may be 5 or 105 rendered rows, and at the bottom I need a total of that variable.

ie:
5
10
25
total: 40.

I have ready about "+=" but can't get it to work.
There will be about 10 other 'sums' to do as well.
I've so far got this:

Code: Select all

<td>£$row->total</td>
<td>£$row->unpaidbills</td>
<td>$row->timespent</td>
<td>£$row->estimate</td>
<td>$row->currentpos<br/>";
$totalsum += $row->total;
echo "$totalsum</td>
</tr>
";
But cannot get anything to render in $totalsum.

Can anyone help please?

Simon

Re: A simple "totalling" query to produce - can't get it right.

Posted: Mon Dec 08, 2008 5:41 am
by pbs
Bring that echo $totalsum out of the loop.