<?php
require_once './shikanisha.kts.php';

$category = isset($_GET['category']) ? $conn->real_escape_string($_GET['category']) : '';

$data = [];

if ($category === 'beverage') {
    $query = "SELECT DISTINCT cat FROM beverages";
    $result = $conn->query($query);
    
    while ($row = $result->fetch_assoc()) {
        $data[] = $row['cat'];
    }
} elseif ($category === 'food') {
    $query = "SELECT DISTINCT food_group FROM food";
    $result = $conn->query($query);
    
    while ($row = $result->fetch_assoc()) {
        $data[] = $row['food_group'];
    }
}

header('Content-Type: application/json');
echo json_encode($data);
?>