1
這裏在a.php文件中只有1行正在顯示。我使用fetch(PDO :: FETCH_ASSOC)stll我沒有從chatlog獲取整行。 問題在哪裏?只選擇一條記錄
a.php只會
<html>
<head>
</head>
<body>
<?php
Include ('connect.php');
$query = $handler->prepare("SELECT message FROM chatlog");
$query->execute();
while ($row = $query->fetch()) {
$message = $row['message'];
$query = $handler->prepare("SELECT * FROM smilies");
$query->execute();
while ($row = $query->fetch()) {
$emoji = $row['emoji'];
$smiley = "<img src='image/" . $row['smiley'] . "'/>";
$message = str_replace($emoji, $smiley, $message);
}
print_r("$message");
}
?>
</body>
</html>
的'$ query'變量。你正在覆蓋它。 –