我的代码有问题,我已经从数据库中选择了浮点值,现在我想减去该值并将更新后的值更新到数据库表中 在我的代码下方。
$AmountGiven = $_POST['AmountGiven'];
$conn = mysqli_connect("localhost","root","","xxx");
$selectuser = "SELECT * FROM users where email='$email'";
if($resultuser = mysqli_query($conn, $selectuser)){
if(mysqli_num_rows($resultuser) > 0){
while($row = mysqli_fetch_array($resultuser)) {
$uuser_id = $row['uid'];
$selctAllAmounttoShow = "SELECT * FROM donate WHERE user_id = '$uuser_id'";
if( $resultToShowAmount = mysqli_query($conn, $selctAllAmounttoShow)){
if( mysqli_num_rows($resultToShowAmount) > 0 ){
while($row = mysqli_fetch_array($resultToShowAmount)) {
$AmountAllToShow = $row['amount']; // these are float values
}
}
}
}
} else {
echo "Login First";
}
}
$updateAmount = "UPDATE donate SET amount = '$AmountAllToShow' - '$AmountGiven' WHERE user_id = '$uuser_id'";
$queryUpdateAmount = mysqli_query($conn,$updateAmount);
if($queryUpdateAmount){
echo "ALL DONE";
} else {
echo "ERROR";
}
$ AmountAllToShow此变量具有两个浮点值,例如0.5、0.7、0.3、0.6 = 2.1。
如果我所有行都有2.1值,那么我如何用1减去这些值,例如2.1-1 = 1.1,然后将此1.1值发送到$ row ['amount']和$ row ['amount']值0.3、0.7、0.1是发送到1.1之间的数据库编号的什么?
请帮助某人,谢谢StackOverFlow。
答案 0 :(得分:0)
尝试
<div class="wrapper">
<div class="item" id="item"></div>
<div class="item1" id="item1"></div>
<div class="item2" id="item2"></div>
<div class="item3" id="item3"></div>
</div>