<?php
require_once '../includes/config.php';

$noti = $pdo->query("SELECT * FROM notifications ORDER BY created_at DESC LIMIT 5")->fetchAll();

foreach ($noti as $n):
?>
<div class="alert alert-warning mb-2 p-2">
  <strong><?= htmlspecialchars($n['message']) ?></strong><br>
  <small><?= $n['created_at'] ?></small>
  <?php if ($n['link']): ?>
    <br><a href="<?= $n['link'] ?>" class="btn btn-sm btn-outline-dark mt-1">View</a>
  <?php endif; ?>
</div>
<?php endforeach; ?>
