<?php
require_once "conexion.php";
header("Content-Type: application/json");

$id = $_GET["id"] ?? 0;
$res = mysqli_query($con, "SELECT id, mesa_id as mesa, hora, detalle FROM comandas_cocina WHERE id = $id");
if ($row = mysqli_fetch_assoc($res)) {
    echo json_encode($row);
} else {
    echo json_encode(["error" => "Comanda no encontrada"]);
}
?>