<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="form.css">
  <link rel="stylesheet" href="tableview.css">
  <link rel="stylesheet" href="mai.css">
  <title>View all Attendees</title>
  <link rel="stylesheet" href="table.css">
</head>
<body>
<?php
// We need to use sessions, so you should always start sessions using the below code.
session_start();
// If the user is not logged in redirect to the login page...
if (!isset($_SESSION['loggedin'])) {
	header('Location: index.html');
	exit;
}
?>




<?php

require 'db.php';
$date= $_POST['date'];




// echo "Haha.. Connected successfully";
$sql = "SELECT *
FROM guest WHERE GuestDate = '$date'" ;

$results = mysqli_query($con, $sql);

if ($results === false) {
  // code...
  echo mysqli_error($con);
} else {
  // code...
  $viewGuests= mysqli_fetch_all($results, MYSQLI_ASSOC);


}
 ?>

  <?php require 'header.php'; ?>
    
       <?php if (empty($viewGuests)):?>
         <p>No Guests found</p>
       <?php else: ?>
       
        <p>List of Guests for <?php echo $_POST['date']; ?></p>
         <?php foreach ($viewGuests as $Guests):  ?>

            <ul>
      <article class="">
        <div><li>
          <?= $Guests['GuestFirstName'] ?>
        <a href="guestTemplate.php?id=<?= $Guests['GuestID']?>"><?= $Guests['GuestLastName']; ?></a> <?= $Guests['GuestPhoneNumber'] ?></li></div>

      </article>
    </ul>
       <?php endforeach; ?>
       </ul>
     <?php endif; ?>
<br>
     <div>
        Make another Search: <?php
        include 'GuestsSearchByDate.php'
        ?>
     </div>

     <?php require 'footer.php' ?>

</body>
</html>
