<?php
include('../includes/db.php');

$class_id = isset($_GET['class_id']) ? intval($_GET['class_id']) : 0;

$query = "SELECT class FROM classes WHERE class_id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $class_id);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    echo json_encode(['success' => true, 'class_name' => $row['class']]);
} else {
    echo json_encode(['success' => false, 'class_name' => 'Unknown']);
}
?>