gpt4 book ai didi

javascript - 我想从字段 (B) 硬币值中减去字段 (A) - coin_charge 值,并将结果存储在字段 (B) 硬币中

转载 作者:行者123 更新时间:2023-11-29 20:48:58 25 4
gpt4 key购买 nike

首先,我在 MySQL 数据库中有两个字段,COIN 和 COIN_CHARGE 字段,这是屏幕截图 POPUP Screnshot ,我希望系统检查用户是否单击"is",即尝试登顶并继续,让系统检查他的数据库 Database screen shot并启动此参数,(如果字段 -coin- 小于字段 -coin_charge-)应该弹出一个窗口,显示资金不足,无法继续充值您的帐户,否则,如果 coin 字段大于 coin_charge 字段,让系统减去coin_charge 来自 coin,即如果 (coin = 100) 且 (coin_charge =50) coin 将变为 50

----------------- 弹出消息 -------------------------- ---

<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Report Assignment</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Report Assignment Now!</h4>
</div>
<div class="modal-body">
<p>You Will Be Charge From Your Portal Account, Do You Wish To Continuo?</p>
</div>
<div class="modal-footer">
<a class="btn btn-primary" data-toggle="modal" onClick="$('#createFormId').modal('show')" >YES</a>

<button type="button" class="btn btn-default" data-dismiss="modal">NO</button>
</div>
</div>

</div>
</div>

----------------------------------------计算代码-------------------- ---------

<?php
$message_query = mysql_query("select * from student ")or die(mysql_error());
?>

<?php
while ($row = mysql_fetch_assoc($results)) {
echo $row['coin'] = $row['coin'] - $row['coin_charge'];
}
?>

最佳答案

$mysqli = new mysqli("localhost", "username", "password", "dbname");
$userid = $_POST["userid"];

$stmt = $mysqli->prepare('SELECT * FROM student WHERE id = ?');
$stmt->bind_param('i', $userid);
$stmt->execute();

$result = $stmt->get_result();
$row = $result->fetch_assoc();
$stmt->close();

$total = $row['coin'] - $row['coin_charge'];
if($total > 0){
$stmt = $mysqli->prepare("update student set coin = ? where id = ?");
$stmt->bind_param("ii", $total, $userid);
$stmt->execute();
$stmt->close();
echo $total;
}else{
echo 'Insufficient Fund to proceed Top Up your account';exit;
}

关于javascript - 我想从字段 (B) 硬币值中减去字段 (A) - coin_charge 值,并将结果存储在字段 (B) 硬币中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38209842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com