<?php
require_once '../config/db.php';
$cat_name = $_GET['cat_name'];
$query = "SELECT s.sub_category_name 
          FROM sub_categories s 
          JOIN categories c ON s.cat_id = c.id 
          WHERE c.category_name = '$cat_name' AND s.status='Active'";
$result = $conn->query($query);
$data = [];
while($row = $result->fetch_assoc()) { $data[] = $row; }
echo json_encode($data);