Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Total

  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    Masai, Johor, Malaysia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Total

    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

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Well I would probably do something like

    PHP Code:
    <?
    $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.

  • #3
    New Coder
    Join Date
    Jul 2007
    Location
    Masai, Johor, Malaysia
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, it did just great..but, I want the output to display in one row for each employee..its something like this:

    PHP Code:
    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..
    Last edited by NiZAM; 07-19-2007 at 03:11 AM. Reason: correction


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •