<?php
session_start();
$conn = mysqli_connect('localhost', 'ahmeuesz_dino', 'X39IW2ho3^5h6d_5', 'ahmeuesz_myapp');
$result = mysqli_query($conn, "SELECT * FROM namaz_table");
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Namaz Records</title>
</head>
<body>
    <h2>Namaz Attendance Records</h2>
    <?php
    if (isset($_GET['msg'])) {
        echo $_GET['msg'] == 'success' ? '<p>Data Added Successfully!</p>' : '<p>Failed to Add Data!</p>';
    }
    ?>
    <table border="1" cellpadding="8">
        <tr>
            <th>Date</th><th>Name</th><th>Fajar</th><th>Zuhar</th><th>Asar</th><th>Maghrib</th><th>Esha</th>
        </tr>
        <?php while ($row = mysqli_fetch_assoc($result)) : ?>
        <tr>
            <td><?= $row['date'] ?></td>
            <td><?= $row['name'] ?></td>
            <td><?= $row['fajar'] ?></td>
            <td><?= $row['zuhar'] ?></td>
            <td><?= $row['asar'] ?></td>
            <td><?= $row['mghrib'] ?></td>
            <td><?= $row['esha'] ?></td>
        </tr>
        <?php endwhile; ?>
    </table>
    <p>
        <a href="form.html">Add Another</a> |
        <a href="logout.php">Logout</a>
    </p>
</body>
</html>
