$result = $pdo->prepare("SELECT * FROM chatbox");
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC))
{
$username = $row['username'];
$message = $row['message'];
echo $username, ' - ', $message, '<br>';
}
?>
所以基本上,这是我用于聊天框系统的代码,我想让它显示前十个最高的chat_id结果,并且它会自动保持更新十个最高。
答案 0 :(得分:1)
SELECT * FROM chatbox
- &GT;
SELECT * FROM chatbox ORDER BY id DESC LIMIT 10