gpt4 book ai didi

Php Mysql插入查询在if条件或直接条件下不起作用

转载 作者:行者123 更新时间:2023-11-29 19:08:43 27 4
gpt4 key购买 nike

Mysql插入查询不是条件下插入。它没有给出任何类型的错误。但更新查询正在工作。请帮忙

//this query gets the status of reward system if its enabled
$reward = mysql_fetch_assoc(mysql_query("
select * from on_off where ename = 'reward' and status = 1
"));
$trueN = $reward['status'];

//this query gets the info if member already exist
// if member record already exist then it will update otherwise it will insert
$rewardz = mysql_query("
select * from rewards where mem_id = 1
");
$trueM = mysql_num_rows($rewardz);

if ($trueN == 1 && $trueM == 1){

mysql_query("
update rewards
set amount = 12
where mem_id = 1
");

}elseif ($trueN == 1 && $trueM == 0){

$insert=mysql_query("INSERT INTO `rewards` (`amount`, `mem_id`)
VALUES (1, 1)");

}

最佳答案

您需要使用mysqli_multi_query()来执行多个查询。在此链接上了解更多信息 http://php.net/manual/en/mysqli.quickstart.multiple-statement.php

关于Php Mysql插入查询在if条件或直接条件下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43266029/

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