Anyone here can help me solve this? I just want to get the total or sum of certain column, please refer to the image below. Been trying to sort this for 2days but cant get no luck, Hope anyone can help me with this. I appreciate it so much, and thanks in advance.
Here is a sample image http://www.freeimagehosting.net/pig81
<?php $sql = "SELECT name, doc_date, descs, debit, credit FROM statement WHERE
member_id = $member_id ORDER BY doc_date";
$query = mysql_query($sql);
$combinedResults = array();
while($result = mysql_fetch_array($query)) {
$combinedResults[$result[`name`]][] = array(`name` => $result[`name`], `doc_date` =>
$result[`doc_date`], `descs` => $result[`descs`],`debit` => $result[`debit`], `credit`
=> $result[`credit`]);}
foreach(array_keys($combinedResults) as $groupKey) { ?>
<table>
<tr><?php foreach($combinedResults[$groupKey] as $item) {?>
<td>Date</td>
<td>Description</td>
<td>Debit</td>
<td>Credit</td>
<td>Balance</td>
</tr>
<tr>
<td colspan="2"><?php echo $groupKey; ?></td>
<td width="105"> </td>
<td width="105"> </td>
<td width="105"> </td>
</tr>
<tr><?php foreach($combinedResults[$groupKey] as $item) {?>
<td><?php echo $item[`doc_date`];?></td>
<td><?php echo $item[`descs`];?></td>
<td><?php echo $item[`debit`];?></td>
<td><?php echo $item[`credit`]; ?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>sum of debit goes here</td>
</tr>
<?php }} ?>
</table>