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

try {
    // Check students for class_id = 10 and session = '2025'
    $stmt = $pdo->prepare("SELECT id, student_id, first_name, last_name, roll_number, guardian_name, group_name FROM students WHERE class_id = ? AND session = ? AND status = 'active' ORDER BY roll_number");
    $stmt->execute([10, '2025']);
    $students = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo "<h2>Students in Class 10, Session 2025:</h2>";
    echo "<p>Total students found: " . count($students) . "</p>";
    
    if (!empty($students)) {
        echo "<table border='1'>";
        echo "<tr><th>ID</th><th>Student ID</th><th>Name</th><th>Roll</th><th>Guardian</th><th>Group</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['roll_number'] . "</td>";
            echo "<td>" . $student['guardian_name'] . "</td>";
            echo "<td>" . ($student['group_name'] ?? 'N/A') . "</td>";
            echo "</tr>";
        }
        echo "</table>";
    } else {
        echo "<p>No active students found for class 10, session 2025</p>";
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>