我想展示另一张桌子。在哪里显示这样。
Date Total Amount
2015-01-29 10,000 BDT
2015-01-30 45,000 BDT
2015-02-02 10,000 BDT
http://i.stack.imgur.com/OjMns.png 我正在尝试PHP。但我可以做得很好。请给我一个解决方案。我是怎么做的
答案 0 :(得分:0)
SELECT `date`, SUM(amount) as `Total_Amount`
FROM your_table_name
GROUP BY `date`
根据你提供的代码,请记住,因为你做了SUM - 你不能说出什么是id行,并且你使用as sum
因为没有归档amount
而是sum
}:
$result = mysqli_query($con,"SELECT date, SUM(amount) as sum FROM deposit GROUP BY date");
echo "<table border='1' > <tr> <th>Id</th> <th>Date</th> <th>Amount</th> </tr>";
$i=0;
while ($row = mysqli_fetch_array($result)) {
$i++;
echo "<tr>"; echo "<td>". $i."</td>";
echo "<td>". $row['date']."</td>";
echo "<td>". $row['sumt']."</td>";
echo "</tr>";
}
echo "</table>";