How can I avoid negative numbers from being inserted in my database table?
i have a code that works but will not prompt until the value itself in the table is below 0.
$nega = mysql_query
("SELECT * from `bgl` where product_code = '$product_code' and stock > 0");
$row = mysql_fetch_array($nega);
if ($row['stock'] > 0){
$query1 = mysql_query("UPDATE `bgl` SET stock = stock - '$quantity'
where product_code = '$product_code'");
die ("<center><font size = 5><br><br><br>Item added to Cart.Continue shopping?
<a href = BGL.php>Y</a> |<a href = homepage.php>N</a>");
}
else echo "</ br>Out of Stock.";
How can I modify this so when the user enters a value, let's say 20 but the value is only 10 in the database, it will not be updated?