Im worink with the 'shop-app' and I want to get error response when a-b<0 , because if user have for example 10$ and an item cost 20$, he cant buy it, but in my app it look that: 10-20=-10 Here is php script:
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
include 'DatabaseConfig.php';
$con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
$id = $_POST['UserID'];
$S_cash = $_POST['Cash'];
$S_substract = $_POST['Substract'];
$Sql_Query = "UPDATE user SET cash= '$S_cash' - '$S_substract' WHERE id = $id";
if(mysqli_query($con,$Sql_Query))
{
echo 'Success!';
}
else
if('$S_cash' - '$S_substract' < 0)
///this is what ive tried
{
echo 'error';
}
}
mysqli_close($con);
?>