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

try {
    // Get the exam with ID 68 (from previous output)
    $stmt = $pdo->prepare("SELECT * FROM exams WHERE id = ?");
    $stmt->execute([68]);
    $exam = $stmt->fetch();
    
    if ($exam) {
        echo "Exam details:\n";
        foreach ($exam as $key => $value) {
            echo "- " . $key . ": " . ($value ?? 'NULL') . "\n";
        }
        
        // Check what sessions exist in the students table
        echo "\nExisting sessions in students table:\n";
        $stmt = $pdo->query("SELECT DISTINCT session FROM students WHERE status = 'active' ORDER BY session");
        $sessions = $stmt->fetchAll();
        foreach ($sessions as $session) {
            echo "- '" . $session['session'] . "'\n";
        }
        
        // Check what sessions exist in the academic_sessions table
        echo "\nSessions in academic_sessions table:\n";
        $stmt = $pdo->query("SELECT * FROM academic_sessions WHERE status = 'active' ORDER BY session_name");
        $academic_sessions = $stmt->fetchAll();
        foreach ($academic_sessions as $session) {
            echo "- '" . $session['session_name'] . "'\n";
        }
    } else {
        echo "No exam found with ID 68\n";
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>