query($sql); $menu = []; while ($row = $stmt->fetch()) { $row['id'] = (int)$row['id']; $row['price'] = (float)$row['price']; $row['stock'] = (int)$row['stock']; $row['popularity'] = (int)$row['popularity']; $cat_emojis = [ 'Beverages' => '🥤', 'Wafers' => '🍪', 'Snacks' => '🍟', 'Coffee & Drinks' => '☕', 'Hot Dogs' => '🌭', 'Biryani' => '🍛' ]; $row['emoji'] = $cat_emojis[$row['category']] ?? '🍽'; $row['cat'] = $row['category']; $row['img'] = $row['image_url']; $row['sub'] = $row['description']; $menu[] = $row; } echo json_encode(['status' => 'success', 'count' => count($menu), 'data' => $menu]); } catch (PDOException $e) { echo json_encode(['status' => 'error', 'message' => 'Query failed', 'error' => $e->getMessage()]); } ?>