0
我已经如何通过更新表PHP
subscription_complete subscription_pending通过包含
id mag1 mag2 mag3 mag4
4 100 0 100 0
包含
id mag1 mag2 mag3 mag4
4 100
我有插入值以下命令
创建两个表subscription_pending和subscription_complete替换数据库值$final_q= "INSERT INTO `subscription_complete` (`id`, `mag1`, `mag2`, `mag3`, `mag4`) VALUES ('".$row_q['id']."','".$row_q['mag1']."','".$row_q['mag2']."','".$row_q['mag3']."','".$row_q['mag4']."'
我想在不更换它的价值,即100,我hvae写下面的查询
$final_q1= "update subscription_complete set mag1='".$row_q['mag1']."',mag2='".$row_q['mag2']."',mag3='".$row_q['mag3']."',mag4='".$row_q['mag4']."' where id='".$row_q['id']."'";
你能告诉我如何设置在剩余的列,其中值是0值100来更新subscription_complete表?
预先感谢您!
**警告**:使用手动转义非常容易出错,并且一个错误可能会导致一个严重的错误[SQL注入漏洞](http://bobby-tables.com/)。尽可能使用**准备好的陈述**。这些在['mysqli'](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)和[PDO](http://php.net/manual/)中很简单en/pdo.prepared-statements.php)其中用户提供的数据是用'?'或':name'指示符指定的,后者使用'bind_param'或'execute'填充,具体取决于您使用的是哪一个。 – tadman
为什么不把它保留在一个表上,并且使用-1或-100,因为用户没有订阅,如果挂起则为0,如果完成则为100?你也可以展示更多的PHP脚本。当然,你所要做的只是更新mag2而不是输入所有的待处理完成? – Matt
我不能区分如何更新什么值,所以我已经使用更新整个表 –