<?php
session_start();
// Memanggil atau membutuhkan file function.php
require 'function.php';

$active_event_id = get_active_event_id();
// Menampilkan semua data dari table tamu berdasarkan nis secara Descending
$tamu= query("SELECT * FROM comment_id WHERE event_id = '$active_event_id' ORDER BY no_id ASC");

// Membuat nama file
$filename = "Daftar Tamu-" . date('Ymd') . ".xls";

// Kodingam untuk export ke excel
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=Daftar Tamu.xls");

?>
<table class="text-center" border="1">
    <thead class="text-center">
        <tr>
            <th>No.</th>
            <th>Nama</th>
            <th>Tanggal</th>
            <th>Jam</th>
            <th>Tamu</th>
            <th>Whatsapp</th>
        </tr>
    </thead>
    <tbody class="text-center">
        <?php $no = 1; ?>
        <?php foreach ($tamu as $row) : ?>
            <tr>
                <td><?= $no++; ?></td>
                <td><?= $row['nama']; ?></td>
                <td><?= $row['tgl']; ?></td>
                <td><?= $row['jam']; ?></td>
                <td><?= $row['tamu']; ?></td>
                <td><?= $row['whatsapp']; ?></td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>