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

// Check if itemId and available are set
if (isset($_POST['itemId'], $_POST['available'])) {
    // Sanitize input
    $itemId = mysqli_real_escape_string($conn, $_POST['itemId']);
    $available = mysqli_real_escape_string($conn, $_POST['available']);

    // Update the availability status in the database
    $sql = "UPDATE menu_items SET available = '$available' WHERE id = '$itemId'";
    if ($conn->query($sql) === TRUE) {
        // Return a success message if needed
        echo "Availability updated successfully";
    } else {
        // Return an error message if needed
        echo "Error updating availability: " . $conn->error;
    }
} else {
    // Return an error message if itemId or available are not set
    echo "Error: itemId or available not set";
}

// Close the database connection
$conn->close();
?>
