【发布时间】:2017-07-09 10:16:38
【问题描述】:
在此表中,我有多个值,例如 CGST、SGST、NET AMOUNT、MRP 我想在下面给定的 CGST、SGCST 等中找到所有值的总和...
请帮助我如何找到所有数据的总数。
这是代码:
<table class="table table-striped">
<thead>
<tr>
<th><strong>Sr. No</strong></th>
<th><strong>Item Name</strong></th>
<th><strong>Serial No</strong></th>
<th><strong>CGST</strong></th>
<th><strong>SGST</strong></th>
<th><strong>NET AMOUNT</strong></th>
<th><strong>MRP</strong></th>
</tr>
</thead>
<tbody>
<?php
$counter = 0;
$getData = mysql_query("SELECT CUSTOMER_ID, ITEM_ID, DATE, FLAG, GROUP_CONCAT(SERIAL_NO) AS SERIAL_NO FROM cart_mst WHERE CUSTOMER_ID = '".$_SESSION['cust']."' AND FLAG = '0' GROUP BY ITEM_ID");
while($row = mysql_fetch_array($getData))
{
$getItem = mysql_query("SELECT * FROM item_details WHERE ITEM_ID = '".$row['ITEM_ID']."'");
$rowItem = mysql_fetch_array($getItem);
?>
<tr>
<td><?php echo ++$counter ?></td>
<td>
<?php echo $rowItem['ITEM_NAME'];
$schools_array = explode(",", $row['SERIAL_NO']);
$qty = count($schools_array);
?>
</td>
<td>
<?php
$hobbies = explode(',', $row['SERIAL_NO']);
foreach ($hobbies as $hobby)
{
// output each hobby and decorate/separate them however you'd like
echo $hobby . ', ';
}
?>
</td>
<td>
<?php
if($rowItem['TYPE'] == "BAT")
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/128;
$cgst = $net_amt * 14/100;
echo round($cgst, 2);
}
else
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/118;
$cgst = $net_amt * 9/100;
echo round($cgst, 2);
}
?>
</td>
<td>
<?php
if($rowItem['TYPE'] == "BAT")
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/128;
$sgst = $net_amt * 14/100;
echo round($cgst, 2);
}
else
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/118;
$cgst = $net_amt * 9/100;
echo round($cgst, 2);
}
?>
</td>
<td>
<?php
if($rowItem['TYPE'] =="BAT")
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/128;
echo round($net_amt, 2);
}
else
{
$mrp = $rowItem['MRP'];
$tot = $mrp * $qty;
$net_amt = $tot * 100/118;
echo round($net_amt, 2);
}
?>
</td>
<td>
<?php
$a = $rowItem['MRP'];
$tot = $a * $qty;
echo $tot;
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
【问题讨论】:
标签: php html-table sum