<?php
require_once 'config/database.php';
try {
    $stmt = $pdo->prepare('SELECT r.*, s.name as subject_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" AND r.marks_obtained < 40 ORDER BY r.marks_obtained ASC');
    $stmt->execute();
    $results = $stmt->fetchAll();
    echo 'Low marks (< 40):' . PHP_EOL;
    foreach ($results as $result) {
        echo $result['subject_name'] . ': ' . $result['marks_obtained'] . PHP_EOL;
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
}
?>

