向数据库添加1的PHP Onclick事件(SQL)
16lz
2021-01-22
Basically, what I am trying to accomplish is being able for the users to click a button on my html site and it adds a 1 to their account balance. How would I do this? I think it would be like this:
基本上,我想要完成的是能够让用户点击我的html网站上的按钮,并为他们的帐户余额增加1。我该怎么做?我想会是这样的:
$sql = "UPDATE balance SET +1 WHERE id=session";
1 个解决方案
#1
$sql= "UPDATE balance SET columnname = columnname + 1 WHERE id = {$SESION['userid']}";
Its advisable to use PDO and parameterized queries
建议使用PDO和参数化查询