prepare("SELECT id FROM restaurants WHERE user_id = ?"); $stmt->execute([$_SESSION['user_id']]); $restaurant = $stmt->fetch(); if ($restaurant) { $restaurant_id = $restaurant['id']; // Delete the menu item only if it belongs to the owner's restaurant $stmt = $pdo->prepare("DELETE FROM menu_items WHERE id = ? AND restaurant_id = ?"); $stmt->execute([$menu_item_id, $restaurant_id]); } } header('Location: menu.php'); exit; ?>