<?php
include('db_connection.php');
session_start();

// Fetch notifications for the logged-in admin
$admin_id = $_SESSION['student_id']; // Assuming student_id is stored in session
$notif_stmt = $conn->prepare("SELECT * FROM group_notifications WHERE student_id = ? AND is_read = FALSE ORDER BY created_at DESC");
$notif_stmt->bind_param('i', $admin_id);
$notif_stmt->execute();
$notifications = $notif_stmt->get_result();
?>

<div class="notifications">
    <h3>Notifications</h3>
    <ul>
        <?php while ($notif = $notifications->fetch_assoc()): ?>
            <li>
                <?= htmlspecialchars($notif['message']) ?>
                <span><?= htmlspecialchars($notif['created_at']) ?></span>
                <a href="mark_as_read.php?notif_id=<?= $notif['notification_id'] ?>">Mark as read</a>
            </li>
        <?php endwhile; ?>
    </ul>
</div>
<?php
$notif_stmt->close();
?>


