<?php

include 'includes/config.php';

header('Content-Type: application/json');

// Fetch categories where id matches the parent_id of other categories
$query = "
    SELECT DISTINCT c1.id, c1.name, c1.parent_id 
    FROM categories c1
    INNER JOIN categories c2 ON c1.id = c2.parent_id
    WHERE c1.business_id = 3
";
$stmt = $conn->query($query);
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($categories);
?>
