In my button the user can add more quantity from his order. What I want is to prevent the user from adding more than the quantity left. The button goes into the cart table. What I want is to connect the product_qty to the cart so that the user cannot abuse the add button.
E.G. Item A ( 5 stocks left ) , User inputs 4 , but the user can abuse it using the button going from 4 to 8.
my product table consists of
productid,
categoryid,
product_name,
product_price,
product_qty,
supplierid,
my cart table consists of
cartid,
userid,
productid,
qty,
This is my php file
<?php
include('session.php');
if(isset($_POST['add'])){
$id=$_POST['id'];
$query=mysqli_query($conn,"select * from cart where productid='$id'");
$row=mysqli_fetch_array($query);
$newqty=$row['qty']+1;
mysqli_query($conn,"update cart set qty='$newqty' where productid='$id'");
}
?>