<?php
include "../user/db.php";
$id = intval($_GET['id']);
$course = $conn->query("SELECT * FROM courses WHERE id=$id")->fetch_assoc();
$modulesRes = $conn->query("SELECT * FROM modules WHERE course_id=$id ORDER BY module_order ASC");
$modules = [];
while($m = $modulesRes->fetch_assoc()) $modules[] = $m;
echo json_encode(['course'=>$course,'modules'=>$modules]);
