$productName = 'Widget'; $quantity = 100; $sql = "INSERT INTO product_stock (product_name, quantity) VALUES ('$productName', $quantity)"; mysqli_query($conn, $sql);
$productName = 'Widget'; $newQuantity = 50; $sql = "UPDATE product_stock SET quantity=$newQuantity WHERE product_name='$productName'"; mysqli_query($conn, $sql);
$productName = 'Widget'; $sql = "SELECT quantity FROM product_stock WHERE product_name='$productName'"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_assoc($result); $quantity = $row['quantity']; echo "There are $quantity Widgets in stock.";This code queries the quantity of the "Widget" product in stock and displays it as a message. Package library: The package library used in this example is likely to be mysqli or PDO, which are both commonly used PHP libraries for connecting to SQL databases and running queries.