如何用通知器减少数量

时间:2014-03-01 03:24:27

标签: php mysql

嗨大家这是我的新手问题...... 我三天前开始学习php了... 这是我的问题...... 例如 当我减去10时,我的数量为50,值50变为40 并且通知程序提醒我该号码小于50 但是当我再次减去它时仍然减少了......

这是我的代码

   if(isset($_POST['submit'])){

$id = $_GET['id'];
$old = $_POST['quantity'];
$new = $_POST['quantity1'];

$total = $new - $old;


if($total < 50 ){

        echo "<h1 style='color: red'><center>CRITICAL LEVEL</center></h1>";
        echo "<script>window.open('inventory.php' , '_self');</script>";

}


else{

$uiqry = $mysqli->prepare("UPDATE table_inventory SET quantity = ?  WHERE id = ?");

$uiqry->bind_param('ii', $total,$id);

$uiqry->execute();
$uiqry->close();
echo "<script>alert('Subracted');</script>";
echo "<script>window.open('inventory.php', '_self');</script>";


}

}

我想要当我的值为50并且我从10减去它时,值现在为40并且警报通知我 当我再次减去10时,值变为30并再次通知弹出窗口 这该怎么做 提前致谢.. 对不起我的绕口令英语..:D

1 个答案:

答案 0 :(得分:0)

if(isset($_POST['submit'])){

    $id = $_GET['id'];
    $old = $_POST['quantity'];
    $new = $_POST['quantity1'];

    $total = $new - $old;


    if($total < 50 ){

        echo "<h1 style='color: red'><center>CRITICAL LEVEL</center></h1>";
        echo "<script>window.open('inventory.php' , '_self');</script>";

    }

    $uiqry = $mysqli->prepare("UPDATE table_inventory SET quantity = ?  WHERE id = ?");
    $uiqry->bind_param('ii', $total,$id);

    $uiqry->execute();
    $uiqry->close();
    echo "<script>alert('Subracted');</script>";
    echo "<script>window.open('inventory.php', '_self');</script>";

}