<?php
include 'includes/config.php';

if (isset($_POST['id'])) {
    $categoryId = $_POST['id'];
    $business_id = 3; // Assuming business_id is 3

    // Fetch subcategories where parent_id matches the selected category ID and business_id matches
    $stmt = $conn->prepare("SELECT id, name FROM categories WHERE parent_id = ? AND business_id = ?");
    $stmt->execute([$categoryId, $business_id]);

    $subcategories = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo json_encode($subcategories);
}
?>
