我正在使用以下代码返回购买详细信息。显示结果如下
Name Qty Value
Product1 30 1000
Product1 45 2000
Product2 20 1500
Product2 25 3000
怎么能总结出pdt的数量和价值并这样显示
Name Qty Value
Product1 75 3000
Product2 45 4500
Total 120 7500
使用 Select Where 子句。
$result = mysql_query("SELECT pdtname,pack,qty,value FROM ist WHERE chemistcode='3121' AND chemistcode='3020' AND companycode = $companycode");
echo "<table id=customers>
<tr>
<th>Product</th>
<th>Pack</th>
<th>Qunatity</th>
<th>Value</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo"<td>" . $row['pdtname'] . "</td>";
echo"<td>" . $row['pack'] . "</td>";
echo"<td>" . $row['qty'] . "</td>";
echo"<td>" . $row['value'] . "</td>";
echo "</tr>";
}
echo "</table>";