【发布时间】:2016-09-28 20:53:08
【问题描述】:
我有一个表格,可以从数据库中选择信息并显示它,我想知道是否有人可以提供代码让我通过单击按钮来更新列?
示例表:(Access=Boolean)
ID - Name - Access
---------------------------
1 - John - 1
---------------------------
2 - Ben - 1
---------------------------
3 - Terry - 0
---------------------------
我的现有按钮基于引导程序,
<button type=\"button\" id=\"passed\" class=\"btn btn-success btn-flat\"><i class=\"fa fa-check\"></i></button>
<button type=\"button\" id=\"insufficient\" class=\"btn btn-danger btn-flat\"><i class=\"fa fa-times\"></i></button>
我希望有这样的东西,ONCLICK button1 运行 $Allowed SQL ONCLICK 按钮2 运行 $NotAllowed SQL
$allowed = mysqli_query($conn," UPDATE users SET Access = "1" WHERE id = '27' ");
$notallowed = mysqli_query($conn," UPDATE users SET Access = "0" WHERE id = '453' ");
【问题讨论】:
-
你标记为 php;使用带有 post 方法的表单和带有命名属性的提交类型的按钮,并在条件语句中使用它们。 JS/jQuery/ajax 也是一种选择
-
您是否尝试过 UPDATE users SET Access = "1" WHERE id in ('27','453','YourValue3','YourValue') 或者您想更新 Access="1", Access="0" 在一个查询中?
-
@Sami 这不是问题所在。再读一遍。
-
欢呼,弗雷德,这听起来可以解决问题。提交并形成
-
@SheaLavington 是的。想让我在答案中写点什么,只是更详细一点?
标签: php forms mysqli sql-update