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

if (isset($_POST['id'])) {
    $id = intval($_POST['id']);

    $stmt = $conn->prepare("SELECT * FROM courses WHERE id = ?");
    $stmt->bind_param("i", $id);
    $stmt->execute();

    $result = $stmt->get_result();
    if ($result->num_rows === 0) {
        echo json_encode(['error' => 'Course not found']);
        exit;
    }

    $data = $result->fetch_assoc();
    echo json_encode($data);
}
?>
