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

$student_id = 6296;

try {
    // Check if student exists
    $stmt = $pdo->prepare('SELECT * FROM students WHERE id = ?');
    $stmt->execute([$student_id]);
    $student = $stmt->fetch();

    if (!$student) {
        echo "Student $student_id not found!<br>";
        exit;
    }

    echo "Student found: {$student['first_name']} {$student['last_name']}<br>";
    echo "Class: {$student['class_id']}<br>";
    echo "Roll: {$student['roll_number']}<br><br>";

    // Check results
    $stmt = $pdo->prepare('SELECT COUNT(*) as count FROM results WHERE student_id = ? AND session = ? AND exam_type = ?');
    $stmt->execute([$student_id, 2025, 'test']);
    $count = $stmt->fetch()['count'];

    echo "Results count for session 2025, exam_type test: $count<br>";

    if ($count == 0) {
        echo "No results found - this might be why marksheet is failing!<br>";
    }

} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "<br>";
}
?>
