<?php
session_start();
include('shikanisha.kts.php'); // Database connection

// SQL query to fetch data
$sql = "SELECT food_id, name, price, cost_price, food_group, category FROM food";

$result = $conn->query($sql);

if ($result->num_rows > 0) {
    $data = array();
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
    echo json_encode(array("data" => $data));
} else {
    echo json_encode(array("data" => [])); // Return empty array if no data found
}

$conn->close();
?>
