<?php
require_once '../config/db.php';
header('Content-Type: application/json');

$cat_id = intval($_GET['cat_id']);
$query = "SELECT id, sub_category_name FROM sub_categories WHERE cat_id = $cat_id AND status = 'Active'";
$result = $conn->query($query);

$subs = [];
while($row = $result->fetch_assoc()) {
    $subs[] = $row;
}
echo json_encode($subs);