<?php
require 'db_config.php';

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Attendance List.xls"');
header('Cache-Control: max-age=0');


$sql = "SELECT * FROM attendance";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo "<h3> 2024 Annual Conference Attendance List</h3>";
    echo "<table border='1'>";
    echo "<tr>
            <th>ID</th>
            <th>Checkin Time</th>
            <th>Participant Type</th>
            <th>Fullname</th>
            <th>Promotional Materials</th>
          </tr>";

while ($row = $result->fetch_assoc()) {
        echo "<tr>
                <td>" . $row['id'] . "</td>
                <td>" . $row['checkin_time'] . "</td>
                <td>" . $row['participant_type'] . "</td>
                <td>" . $row['fullname'] . "</td>
                <td>" . $row['promotion_material'] . "</td>
              </tr>";
    }
    echo "</table>";
} else {
    echo "No registered users found.";
}

$conn->close();
?>
