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

try {
    // Check exam_subjects table structure
    $stmt = $pdo->query('DESCRIBE exam_subjects');
    $columns = $stmt->fetchAll();
    echo "exam_subjects table structure:\n";
    foreach ($columns as $column) {
        echo "- " . $column['Field'] . " (" . $column['Type'] . ")\n";
    }
    
    // Check if there are any exam subjects
    echo "\nChecking exam subjects:\n";
    $stmt = $pdo->query("SELECT COUNT(*) as count FROM exam_subjects");
    $result = $stmt->fetch();
    echo "Total exam subjects: " . $result['count'] . "\n";
    
    if ($result['count'] > 0) {
        // Get sample data
        $stmt = $pdo->query("SELECT es.*, s.name as subject_name FROM exam_subjects es JOIN subjects s ON es.subject_id = s.id LIMIT 5");
        $subjects = $stmt->fetchAll();
        echo "Sample exam subjects:\n";
        foreach ($subjects as $subject) {
            echo "- Exam ID: " . $subject['exam_id'] . ", Subject: " . $subject['subject_name'] . ", Date: " . $subject['exam_date'] . "\n";
        }
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>