我想顯示我創建的數據庫中的所有數據,但它不顯示所有數據只顯示最近添加的數據。有人能告訴我我的代碼有什麼問題嗎?非常感謝你!顯示來自mysql數據庫的數據
<?php
include 'dbconnect.php';
$query = $db->prepare("SELECT
game_id,
game_name,
history_description,
pl_id
FROM game_post");
$query->execute();
$query->bind_result($game_id, $game_name, $history_description, $pl_id);
?>
<!DOCTYPE html>
<html>
<head>
<title>Trying</title>
</head>
<body>
<?php
while ($query->fetch()); ?>
<article>
<h2><?php echo $game_name; ?></h2>
<p><?php echo $history_description; ?></p>
<p><?php echo $pl_id ; ?></p>
</article>
</body>
</html>
RTM http://php.net/manual/en/mysqli-stmt。 fetch.php –