我正在使用留言簿與分頁。 因此,在url中是這樣的:http://example.com/guestbook/guestbook.php?page=6 當在還不存在的url中輸入一個頁面(例如page = 9999) 他給了我回聲:「成爲第一個寫在留言簿中的人」 How我可以把所有那些不存在的頁面放到404上嗎?如何在頁面不存在時爲留言簿添加404
if (mysqli_num_rows($results) != 0) { // if DB is not empty
// display records
while ($row = mysqli_fetch_array($results))
{ ?>
<div class="wrapper">
<div class="velden"> <!-- for styling echos; CSS -->
<div class="header">
<div class="naam"><?php echo htmlspecialchars($row['name'], ENT_QUOTES, UTF-8, true); ?></div> <!-- echo naam-->
<div class="email"><?php echo htmlspecialchars($row['email'], ENT_QUOTES, UTF-8, true); ?></div> <!-- echo email-->
<div class="tijd"><?php echo $row['datetime']; ?></div> <!-- echo datum en tijd-->
</div>
<div class="bericht"><?php echo htmlspecialchars($row['message'], ENT_QUOTES, UTF-8, true); ?></div> <!-- echo bericht-->
</div> <!-- end velden -->
<?php } ?>
<?php echo pagination($statement,$per_page,$page,$url='?'); ?>
</div>
<?php } else { // DB is emtpy
echo "Be the first to write in the Guestbook";
}
你是說要返回頭404? – 2015-04-03 18:49:28
是的,這是真的;在這種情況下返回一個404頭,而不是回聲 – 2015-04-03 19:01:43