<?php
include 'connect.php';

if(isset($_POST['product_id'])) {
    $id = (int)$_POST['product_id'];
    $sql = "SELECT qty_Onhand FROM products_table WHERE product_id = $id LIMIT 1";
    $result = $conn->query($sql);
    if($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        echo $row['qty_Onhand'];
    } else {
        echo '0';
    }
}
