php - Count Field Content On Table -


count

i have table, how count field content count columns (30+15+20) on php script?
if has snippet, source code or tutorial, please tell me :)

foreach($row->result_array() $row) {    <td><div align="center"><?php echo $row['no']; ?></div></td>    <td><div align="center"><?php echo $row['count']; ?></div></td> } 

initialize variable value 0 ... use += add values $total

$total = 0;  foreach($row->result_array() $row) {    $total += $row['count']; //add loop    /* doing here adding value of $row['count'] $total       $total value available on each iteration , keep on adding       values of $row['count']    */ ?>    <td><div align="center"><?php echo $row['no']; ?></div></td>    <td><div align="center"><?php echo $row['count']; ?></div></td> <?php  }  echo $total; 

alternatively preferable way use sum() in query


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -