I was trying to sum the values if the same id repeat in for loop
<?php 
    $tax = count($_POST['tax_id']);
    for($i=0;$i<$tax;$i++) { 
        $tax_id = $_POST['tax_id'][$i]; 
        $tax_amount = $_POST['amount'][$i];
        $sql = "SELECT * FROM `ca_taxmaster` where tax_comp = $tax_id ";
        $now = mysql_query($sql) or die(mysql_error()); 
        while($row1 = mysql_fetch_array($now)){
            $per = $row1['tax_Percent'];            
            $tax_calc = ($tax_amount*$per)/100;
            $sum_total += $tax_calc;
?>
<tr>
    <td class="text-right" colspan="5"><b><?php echo $row1['tax_type']; ?></b></td>
    <td class="text-right"></td>
    <td class="text-right"><?php echo $tax_calc;?></td>
</tr>
<?php } } ?>
my output like in tax colum for Gst I has sgst&cgst if I select second time I need the sum of sgst&cgst
  No.   Job          Description    SAC Code        Tax       Amount
   0    teaching           desc1    sa001           GST     -   1000
   1    engineer           desc2    sac002    IGST-Master   -   2000
   2    doctor             desc3    sac003          GST     -   1000
                                               Sub-Total        Rs.4000
                                                    SGST        90
                                                    CGST        90
                                                    IGST        360
                                                    SGST        90
                                                    CGST        90
                                                   Total        Rs.4720
but I need to get If same id repeating it should sum the values
                                                    SGST        180
                                                    CGST        180
                                                    IGST        360
                                                   Total        Rs.4720
and my sql structure like: sql table structure
Please help me if it has anyother way to do.Thanks in advance
 
     
     
     
    