<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="table.css">
  <link rel="stylesheet" href="main.css">
  <title>View all Attendees</title>
  <link rel="stylesheet" href="table.css">
</head>
<body>
<?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...
  $viewAttendees= mysqli_fetch_all($results, MYSQLI_ASSOC);


}
 ?>

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

         <table id="Attendees"><ul>
           <tr>
             <th> First Name</th>
             <th> Last Name</th>
             <th> Date</th>
           </tr>

           <tr>
             <td><a href="guestTemplate.php?id=<?= $Guests['GuestID']?>"><?= $attendees['GuestFirstName'] ?></td>
             <td><a href="guestTemplate.php?id=<?= $Guests['GuestID']?>"><?= $attendees['GuestLastName'] ?></td>
             <td><?= $attendees['GuestDate'] ?></td>
           </tr>
         </table>
       <?php endforeach; ?>
       </ul>
     <?php endif; ?>
<br>
     <div>
        Make another Search: <?php
        include 'GuestsSearchByDate.php'
        ?>
     </div>

     <?php require 'footer.php' ?>

</body>
</html>
