我总是无法理解如何使用循环正确生成无序列表。但现在我必须生成一个并将数据库中的数据插入其中。这就是我从数据库中检索数据的方法。
$sql_history = "SELECT * FROM transaction_summary WHERE transaction_Sender='$username' OR transaction_Recipient='$username' ORDER BY id DESC LIMIT 10";
$query = mysqli_query($db, $sql_history);
$row = mysqli_fetch_array($query);
$sender = $row['transaction_Sender'];
$recipient = $row['transaction_Recipient'];
$amount = $row['transaction_Amount'];
如何在无序列表中显示最新的10行?谢谢。
答案 0 :(得分:0)
$row = mysqli_fetch_array($query);
上面的行将第一条记录分配给名为$ row的数组。您需要对查询返回的每条记录执行此操作。所以你应该这样做:
while($row = mysqli_fetch_array($query))
{
$sender = $row['transaction_Sender'];
$recipient = $row['transaction_Recipient'];
$amount = $row['transaction_Amount'];
}