How to sum this table ???

Xelmep 25 Jan, 2014
how to SUM values from column like on picture below.

I arr <tr> in a footer of connection, and now i need to sum values from columnt where status = 0

Any one can help me with php code of SQL ???
Thank you

How to sum this table ??? image 1
GreyHead 25 Jan, 2014
Hi Xelmep,

In the Header box add code like this:
<?php
global $sum;
$sum = 0;
?>

In the Row box add
<?php
global $sum;
$sum += $row['col_name'];
?>

and in the footer:
<?php
global $sum;
echo $sum;
?>


Bob

PS You've already asked this question in another thread, please try not to double post.
Xelmep 25 Jan, 2014
Sorry Bob for duble asking, please remove first thred, and i put your code in my site, and i have result 0 (zero) in total/
Xelmep 25 Jan, 2014
I put this code in heade


<?php
global $sum;
$sum = 0;
?>


If i change
$sum = 1

then in TOTAL results i will see 1

Where is the problem ???

P.S. other 2 codes i put in RowBox TOTAL in Footer, Am i correct ???
GreyHead 25 Jan, 2014
Hi Xelmep,

At a guess you didn't change 'col_name' to the name of the column you wanted to total???

Bob
Xelmep 25 Jan, 2014
or course my column name is 'cena' of course i changed it, if you can you can login again and see, you have info in PM.
Xelmep 25 Jan, 2014
'cena' is column name for price, and now this is code:


<?php
global $sum;
$sum = 0;
?>


Code 2+3 in TOTAL Row box in footer


 <th scope="col">TOTAL:</th>
<th scope="col">
<?php
global $sum;
$sum += $row['cena'];
?>    
<?php
echo $sum;
?></th>
GreyHead 25 Jan, 2014
Hi Xelmep,

It's just past midnight on Saturday night so I shan't look at your site right now, Please check my post about 'where' the code goes though.

Bob
Xelmep 26 Jan, 2014
Ok Bob,

Thank you a lot, i hope today you can see litlle in my site.

Thanks.
Xelmep.
GreyHead 26 Jan, 2014
HI Xelmep,

It's working now, part of the code needed to be moved from the Footer into the Body box (in my post I called it the Row box my mistake).

Bob
This topic is locked and no more replies can be posted.