我想从用户输入中选择产品以图表产品来购买我的网站 产品,但有关mysqli_fetch_array的错误。我不知道如何解决此错误
<?php
$total=0;
if(!empty($_SESSION['cart']))
{
include("Config.php");
foreach($_SESSION['cart'] as $pid2=>$qty)
{
$sql = "select * from product where pid=$pid2";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_array($query) ;
$sum = $row['price'] * $qty;
$total += $sum;
echo "<tr>";
echo "<td width='334'>" . $row["pname"] . "</td>";
echo "<td width='46' align='right'>" .number_format($row["price"],2) . "</td>";
echo "<td width='57' align='right'>";
echo "<input type='text' name='amount[$pid2]' value='$qty' size='2'/></td>";
echo "<td width='93' align='right'>".number_format($sum,2)."</td>";
//remove product
echo "<td width='46' align='center'><a href='cart.php?pid=$pid2&act=remove'>ลบ</a></td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan='3' bgcolor='#CEE7FF' align='center'><b>ราคารวม</b></td>";
echo "<td align='right' bgcolor='#CEE7FF'>"."<b>".number_format($total,2)."</b>"."</td>";
echo "<td align='left' bgcolor='#CEE7FF'></td>";
echo "</tr>";
}
?>