<?php
include("db/cn.php");

if(isset($_POST['product_id'])) {
    $productId = $_POST['product_id'];

    // Fetch product details from the database
    $product_query = "SELECT * FROM products WHERE product_id = $productId";
    $product_result = $connection->query($product_query);

    if ($product_result->num_rows > 0) {
        $row = $product_result->fetch_assoc();
        // Prepare HTML to display product details
        $productDetails = '<p><strong>Name:</strong> ' . $row["name"] . '</p>' .
                          '<p><strong>Supplier:</strong> ' . $row["supplier_name"] . '</p>' .
                          '<p><strong>Batch:</strong> ' . $row["batch_no"] . '</p>' .
                          '<p><strong>Expiry:</strong> ' . $row["expiry"] . '</p>' .
                          '<p><strong>Rack No:</strong> ' . $row["rack_no"] . '</p>' .
                          '<p><strong>Price:</strong> Rs ' . $row["price"] . ' /-</p>';
        echo $productDetails;
    } else {
        echo "Product not found";
    }
} else {
    echo "Product ID not provided";
}
?>