prepare("SELECT name, address, phone FROM restaurants WHERE id = :id"); $stmt->execute(['id' => $restaurant_id]); $restaurant = $stmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { error_log("DB error fetching restaurant: " . $e->getMessage()); // Show a generic error page to the user die("Error: Could not load restaurant information."); } if (!$restaurant) { // Redirect or show a 404 page header("Location: index.php?error=not_found"); exit; } $is_favorite = false; if (isset($_SESSION['user_id'])) { $stmt = $pdo->prepare("SELECT id FROM favorite_restaurants WHERE user_id = ? AND restaurant_id = ?"); $stmt->execute([$_SESSION['user_id'], $restaurant_id]); if ($stmt->fetch()) { $is_favorite = true; } } // Fetch menu items $menu_items = []; try { $stmt = $pdo->prepare("SELECT name, description, price, category FROM menu_items WHERE restaurant_id = :restaurant_id ORDER BY category, name"); $stmt->execute(['restaurant_id' => $restaurant_id]); $menu_items = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { error_log("DB error fetching menu items: " . $e->getMessage()); // It's okay to show the restaurant info even if menu fails to load } // Group menu items by category $menu_by_category = []; foreach ($menu_items as $item) { $category = $item['category'] ?: 'Uncategorized'; $menu_by_category[$category][] = $item; } ?>

This restaurant hasn't added any menu items yet.

$items): ?>