I am using a guestbook with pagination. So in the url is something like: http://example.com/guestbook/guestbook.php?page=6 When typing a page in the url which does not exist yet, (for instance page=9999) he gives me the echo: "Be the first to write in the Guestbook" How can i put a 404 to all those pages which do not exist yet?
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";
}