<?php
require_once 'config.php';
checkLogin();

$results = $db->query("SELECT * FROM bogor_results ORDER BY draw_date_bogor DESC")->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html>
<head>
    <title>Result Bogor - Admin Panel</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.1/css/all.min.css">
</head>
<body>
<?php include 'navbar.php'; ?>

<div class="container mt-4">
    <h3><i class="fas fa-list"></i> Daftar Result Pasaran <strong>BOGOR</strong></h3>
    <div class="table-responsive">
        <table class="table table-bordered table-striped mt-3">
            <thead class="thead-dark">
                <tr>
                    <th>Tanggal</th>
                    <th>Draw No</th>
                    <th>Waktu</th>
                    <th>1st</th>
                    <th>2nd</th>
                    <th>3rd</th>
                    <th>Starter</th>
                    <th>Consolation</th>
                </tr>
            </thead>
            <tbody>
                <?php if (count($results) > 0): ?>
                    <?php foreach ($results as $row): ?>
                        <tr>
                            <td><?= htmlspecialchars($row['draw_date_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['draw_number_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['result_time_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['first_prize_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['second_prize_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['third_prize_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['starter_prize_bogor']) ?></td>
                            <td><?= htmlspecialchars($row['consolation_prize_bogor']) ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr>
                        <td colspan="8" class="text-center">Belum ada data result untuk Bogor.</td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
    <a href="tambah_result.php" class="btn btn-primary"><i class="fas fa-plus-circle"></i> Tambah Result</a>
</div>

</body>
</html>
