...

View Full Version : Total



NiZAM
07-17-2007, 12:26 PM
how to sum a total of amount using PHP. the data get from the MySQL database.

here are the display:

<tr class="12">
<td width="3%"><?php echo $var_i ?></td>
<td width="3%" height="20" ><?php echo $rs_hptrx_link->Fields('emp_Id'); ?></td>
<td width="9%"><?php echo $rs_hptrx_link->Fields('emp_Name'); ?></td>
<td width="5%"><?php echo $rs_hptrx_link->Fields('TRX_DATE'); ?></td>
<td width="5%"><?php echo $rs_hptrx_link->Fields('AMOUNT'); ?></td>
<td width="5%"></td>
<td width="5%"></td>
<td width="5%">&nbsp;</td>
<td width="5%">&nbsp;</td>
<td width="5%"><?php echo $rs_hptrx_link->Fields('TRX_CODE'); ?></td>

I want to sum the AMOUNT from hptrx table for each TRX_CODE and employee. can anyone please help me..TQ

NancyJ
07-17-2007, 01:01 PM
Well I would probably do something like



<?
$totals[$rs_hptrx_link->Fields('TRX_CODE')][$rs_hptrx_link->Fields('emp_Name')] +=$rs_hptrx_link->Fields('AMOUNT');
?>

which should give you an array of totals.

NiZAM
07-19-2007, 03:07 AM
Thanks, it did just great..but, I want the output to display in one row for each employee..its something like this:


NO EMPNO NAME OT1 OT2 OT3 OT4 OT5
1 2006 SAZALI MARZUKI 241.56 628.46
2 2027 BURHAM TARSIWAN 252.55 134.69 134.69 151.53
3 2043 MUTAN PALANISAMY 23 368.08 245.38
4 2141 RAMLI MARLAN 202.04


of course,it will be inside a table..really need your help..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum