<?php
require 'db_connection.php';

$product_id = $_GET['product_id'];

$sql = "SELECT Quantity FROM product WHERE Product_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $product_id);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    echo json_encode(["stock" => $row['Quantity']]);
} else {
    echo json_encode(["stock" => 0]);
}
?>
