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

try {
    $stmt = $pdo->query('SELECT id, name, code FROM subjects WHERE status = "active" ORDER BY code');
    $subjects = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo "Active Subjects:\n";
    echo "===============\n";
    foreach ($subjects as $subject) {
        echo "ID: " . $subject['id'] . " | Code: " . $subject['code'] . " | Name: " . $subject['name'] . "\n";
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
?>