這裏是我的代碼:
<table width="50%" border="2" bordercolor="green">
<tr>
<th>ItemName</th>
<th>Balance</th>
</tr>
<?php
if($qw="select DISTINCT(itemname) from details where DATE(date)<='$date' order by date desc"){
$qq = mysqli_query($con,$qw);
while($r=mysqli_fetch_array($qq,MYSQLI_ASSOC))
{
?>
<tr>
<td><?php echo $r['itemname']; ?></td>
<td><?php echo $r['balance']; ?></td>
</tr>
<?php
}
}
?>
</table>
給定的代碼是獲取產品ITEMNAME但平衡不是從數據庫中獲取。
因爲您不在SQL中選擇'balance'。 – Jeff
'SELECT DISTINCT(itemname),balance ...' – Saty
select DISTINCT(itemname),從DATE(date)<='$ date'按日期排序的詳細信息的餘額desc –