<?php
session_start();
if (!isset($_SESSION['admin_id'])) { header('Location: login.php'); exit; }
include '../db.php';

$admins = $pdo->query("SELECT * FROM admins")->fetchAll();
?>



<?php include 'menu.php'; ?>
<!DOCTYPE html>
<html>
<head><title>Manage Admins</title><link rel="stylesheet" href="../style.css"></head>
<body>
<h2>Manage Admins</h2>
<a href="add_admin.php">➕ Add New Admin</a>
<table border="1" cellpadding="5">
<tr><th>ID</th><th>Username</th><th>Action</th></tr>
<?php foreach($admins as $a): ?>
<tr>
  <td><?= $a['id'] ?></td>
  <td><?= htmlspecialchars($a['username']) ?></td>
  <td>
    <?php if($a['id'] != $_SESSION['admin_id']): ?>
      <a href="delete_admin.php?id=<?= $a['id'] ?>" onclick="return confirm('Delete admin?');">🗑 Delete</a>
    <?php else: ?>
      (you)
    <?php endif; ?>
  </td>
</tr>
<?php endforeach; ?>
</table>
</body></html>
