更新数据库,然后一旦PHP
我总金额。当我出售AM商品时,我想将该金额添加到我的总数中。例如,我有100.00,我以100.00的价格出售蛇,因此我的总数应该为200.00。我的工作正常,所以它增加了100.00,但是如果我想出售两条蛇,它将保持在200.00,它不会增加第二条蛇的任何数量。使用它来更新我的数据库。
if(isset($_POST['go'])
{
$query = "UPDATE users SET amount=$current WHERE email = '".$_SESSION['email']."'";
}
if(isset($_POST['go']) //edit 17.06.2022
{
$current = $amount+100;
}
I have a total amount. when i sell am item i want to add that amount to my total. e.g i have 100.00, i sell a snake for 100.00 so my total should be 200.00. I have it working so it adds the 100.00 but if i want to sell two snakes it will stay at 200.00 it wont add any amount from the second snake. using this to update my database.
if(isset($_POST['go'])
{
$query = "UPDATE users SET amount=$current WHERE email = '".$_SESSION['email']."'";
}
if(isset($_POST['go']) //edit 17.06.2022
{
$current = $amount+100;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码运行在顺序中,因此对
$ current
进行的更改将无法保存在任何地方当前请求。如果要更新数据库中的值,则需要在SQL查询之前将计算移至。
Your code runs in order, so changes made to
$current
after you've run the SQL won't be saved anywhere, they'll just be thrown away at the end of the current request.If you want to update the value in the database, you need to move the calculation to before the SQL query.
$ db的$当前数量是从下面的连接文件中
添加以下行,然后与DB进行交互。
当您让它运行时,建议您查看准备的陈述以防止应用程序上的SQL注入漏洞
$db is from the connection file below
Add the below line before interacting with the DB.
When you get it to run, I suggest looking at prepared statements to prevent SQL injection vulnerabilities on your app