<?php
require_once 'config/database.php';
try {
    $stmt = $pdo->prepare('SELECT COUNT(*) as count FROM results WHERE student_id = 6279 AND session = 2025 AND exam_type = "final"');
    $stmt->execute();
    $count = $stmt->fetch();
    echo 'Total results for student 6279 session 2025 final: ' . $count['count'] . PHP_EOL;

    $stmt = $pdo->prepare('SELECT DISTINCT s.name FROM results r LEFT JOIN subjects s ON r.subject_id = s.id WHERE r.student_id = 6279 AND r.session = 2025 AND r.exam_type = "final"');
    $stmt->execute();
    $subjects = $stmt->fetchAll();
    echo 'Subjects with results:' . PHP_EOL;
    foreach ($subjects as $subject) {
        echo $subject['name'] . PHP_EOL;
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
?>

