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

echo "Sessions in students table:\n";
$stmt = $pdo->query("SELECT DISTINCT session FROM students WHERE session IS NOT NULL AND session != '' ORDER BY session");
$sessions = $stmt->fetchAll(PDO::FETCH_COLUMN);
foreach ($sessions as $session) {
    echo "- '$session'\n";
}

echo "\nChecking if sessions in students table exist in academic_sessions:\n";
foreach ($sessions as $session) {
    $stmt = $pdo->prepare("SELECT COUNT(*) as count FROM academic_sessions WHERE session_name = ?");
    $stmt->execute([$session]);
    $result = $stmt->fetch();
    $exists = $result['count'] > 0 ? "YES" : "NO";
    echo "- Session '$session' in academic_sessions: $exists\n";
}
?>