<?php
include 'config.php';
checkAdminAuth();

$id = intval($_GET['id']);

$meal = $conn->query("SELECT * FROM meals WHERE id='$id'")->fetch_assoc();
$portions = $conn->query("SELECT * FROM meal_portions WHERE meal_id='$id'")->fetch_all(MYSQLI_ASSOC);

echo json_encode([
    'meal' => $meal,
    'portions' => $portions
]);
?>