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

echo "<h3>Available Student IDs</h3>";

try {
    $stmt = $pdo->query("SELECT id, first_name, last_name, student_id, user_id FROM students ORDER BY id DESC LIMIT 20");
    $students = $stmt->fetchAll();
    
    if ($students) {
        echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
        echo "<tr><th>Database ID</th><th>Student ID</th><th>Name</th><th>User ID</th><th>Delete Link</th></tr>";
        
        foreach ($students as $student) {
            echo "<tr>";
            echo "<td>" . $student['id'] . "</td>";
            echo "<td>" . $student['student_id'] . "</td>";
            echo "<td>" . $student['first_name'] . " " . $student['last_name'] . "</td>";
            echo "<td>" . ($student['user_id'] ? $student['user_id'] : 'NULL') . "</td>";
            echo "<td><a href='delete.php?id=" . $student['id'] . "'>Delete</a></td>";
            echo "</tr>";
        }
        echo "</table>";
        
        echo "<p><strong>Note:</strong> Delete link এ click করার আগে নিশ্চিত হন যে আপনি admin হিসেবে logged in আছেন।</p>";
    } else {
        echo "<p>No students found</p>";
    }
    
} catch (Exception $e) {
    echo "<p style='color: red;'>Error: " . $e->getMessage() . "</p>";
}
?>