php - Count Field Content On Table -
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
Post a Comment