<?php
// Include the database configuration file
include 'config.php';

// Query to fetch menu items from the database
$sql = "SELECT * FROM menu_items";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    while ($row = $result->fetch_assoc()) {
        // HTML code for displaying each menu item
        echo '<div class="menu-item-3">';
        echo '<img src="' . $row["image"] . '" alt="Food Image">';
        echo '<div class="menu-food">';
        echo '<h3>' . $row["name"] . '</h3>';
        echo '<p>RM:' . $row["price"] . '</p>';
        echo '<form class="add-to-cart-form-food" method="POST">';
        echo '<input type="hidden" name="item_name" value="' . $row["name"] . '">';
        echo '<input type="hidden" name="item_price" value="' . $row["price"] . '">';
        echo '<input type="number" name="quantity" value="1">';
        echo '<input type="hidden" name="item_image" value="' . $row["image"] . '">';
        echo '<button type="submit" class="add-to-cart-btn" name="add_to_cart">Add to Cart</button>';
        echo '</form>';
        echo '</div>';
        echo '</div>';
    }
} else {
    echo "No items found in the menu.";
}

$conn->close();
?>
