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

$stmt = $pdo->prepare('SELECT * FROM students WHERE id = ?');
$stmt->execute([6279]);
$student = $stmt->fetch();

if ($student) {
    echo 'Student found: ' . $student['first_name'] . ' ' . $student['last_name'] . ' (ID: 6279)' . PHP_EOL;
    echo 'Class ID: ' . $student['class_id'] . PHP_EOL;
    echo 'Group: ' . $student['group_name'] . PHP_EOL;
} else {
    echo 'Student ID 6279 not found in database' . PHP_EOL;
}

// Also check if the student has results for class 10, session 2025, exam_type test
$stmt = $pdo->prepare('SELECT COUNT(*) as count FROM results WHERE student_id = ? AND session = ? AND exam_type = ?');
$stmt->execute([6279, '2025', 'test']);
$result_count = $stmt->fetch();

echo 'Results count for student 6279 with session 2025 and exam_type test: ' . $result_count['count'] . PHP_EOL;

// Check all results for this student
$stmt = $pdo->prepare('SELECT * FROM results WHERE student_id = ?');
$stmt->execute([6279]);
$results = $stmt->fetchAll();

echo 'All results for student 6279:' . PHP_EOL;
foreach ($results as $result) {
    echo '  Result ID: ' . $result['id'] . ', Subject ID: ' . $result['subject_id'] . ', Session: ' . $result['session'] . ', Exam: ' . $result['exam_type'] . PHP_EOL;
}

// Check subjects for this student
$stmt = $pdo->prepare('SELECT ss.*, s.name as subject_name FROM student_subjects ss JOIN subjects s ON ss.subject_id = s.id WHERE ss.student_id = ?');
$stmt->execute([6279]);
$subjects = $stmt->fetchAll();

echo 'All subjects for student 6279:' . PHP_EOL;
foreach ($subjects as $subject) {
    echo '  Subject ID: ' . $subject['subject_id'] . ', Name: ' . $subject['subject_name'] . ', Is Fourth: ' . ($subject['is_fourth_subject'] ? 'Yes' : 'No') . PHP_EOL;
}
?>