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

// Check the structure of results for student ID 6185
$student_id = 6185;
$session = '2025';
$exam_type = 'midterm';

$stmt = $pdo->prepare("
    SELECT r.*, sub.name as subject_name
    FROM results r
    LEFT JOIN subjects sub ON r.subject_id = sub.id
    WHERE r.student_id = ? AND r.session = ? AND r.exam_type = ?
    ORDER BY sub.name
");
$stmt->execute([$student_id, $session, $exam_type]);
$results = $stmt->fetchAll();

echo "=== RESULT STRUCTURE ANALYSIS ===\n\n";

if (!empty($results)) {
    echo "Available fields in results:\n";
    $fields = array_keys($results[0]);
    foreach ($fields as $field) {
        echo "- $field\n";
    }
    
    echo "\nSample data for first result:\n";
    foreach ($results[0] as $key => $value) {
        echo "$key: " . ($value ?? 'NULL') . "\n";
    }
} else {
    echo "No results found for student ID $student_id, session $session, exam_type $exam_type\n";
}

echo "\n=== ANALYSIS COMPLETE ===\n";
?>