我希望代码能够正常工作,以便当用户赚取金额时应将其添加到表中,例如,添加后应包含用户金额+ 赚取Paid我的代码当前在每个声明上添加一个新行,但如果表中已有 a,我希望更新用户的余额。address示例:用户余额为 15.2,他们赚取了 2.3,此余额应更新为 17.5$address = trim($_POST["address"]);$q = $sql->prepare("INSERT INTO ".$dbtable_prefix."Paid SET `address` = ?, `amount` = ? ;");$claimlog_reward = $reward;if ($reward<1) { $claimlog_reward = number_format($reward, 8, '.', '');}$q->execute(array(trim($_POST['address']), $claimlog_reward));
1 回答
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
我将假设MySQL / MariaDB - 添加更新(前提是您的地址是主键)ON DUPLICATE KEY
$address = trim($_POST["address"]);
$claimlog_reward = $reward;
if ($reward<1) {
$claimlog_reward = number_format($reward, 8, '.', '');
}
$q = $sql->prepare("INSERT INTO ".$dbtable_prefix."Paid
SET `address` = :address, `amount` = :amount
ON DUPLICATE KEY UPDATE amount = amount + :amount");
$q->bindValue(':address', trim($_POST['address']));
$q->bindValue(':amount', $claimlog_reward);
$q->execute();
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报
0/150
提交
取消