<?php
require_once __DIR__ . '/../includes/auth.php';
header('Content-Type: application/json');

$cid = (int)($_GET['category_id'] ?? 0);
$out = [];
$res = $conn->query("SELECT id, name FROM subcategories WHERE category_id=$cid ORDER BY name");
while ($r = $res->fetch_assoc()) $out[] = $r;
echo json_encode($out);
