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

$subject_id = 35;

// Check what subject ID 35 is
$stmt = $pdo->prepare("SELECT id, name, code FROM subjects WHERE id = ?");
$stmt->execute([$subject_id]);
$subject = $stmt->fetch();

if ($subject) {
    echo "Subject ID $subject_id: {$subject['name']} ({$subject['code']})\n";
} else {
    echo "Subject ID $subject_id not found!\n";
}

// Check what subjects are available for class 10
echo "\nSubjects available for class 10:\n";
$stmt = $pdo->prepare("SELECT s.id, s.name, s.code 
                       FROM class_subjects cs
                       JOIN subjects s ON cs.subject_id = s.id
                       WHERE cs.class_id = ? AND s.status='active'
                       ORDER BY s.name");
$stmt->execute([10]);
$subjects = $stmt->fetchAll();
foreach ($subjects as $subj) {
    echo "- ID: {$subj['id']}, Name: {$subj['name']} ({$subj['code']})\n";
}

// Check if subject 35 is assigned to class 10
$stmt = $pdo->prepare("SELECT COUNT(*) as count FROM class_subjects WHERE class_id = ? AND subject_id = ?");
$stmt->execute([10, 35]);
$result = $stmt->fetch();
echo "\nIs subject 35 assigned to class 10? " . ($result['count'] > 0 ? "YES" : "NO") . "\n";
?>