我想用多个where条件更新我的表,例如表名是zz
+----+------+------+
| id | X1 | X2 |
+----+------+------+
| 1 | xya | Abc |
| 2 | yaz | xyz |
| 3 | wee | xsc |
| 4 | fss | xcs |
| 5 | eer| XXX |
+----+------+------+
我的问题是这样的
UPDATE `zz` SET `x1` = 'hi' WHERE `zz.`id` = 1 and zz.`id` = 2 and zz.`id` = 3
通过如下复选框选择“id”
<html>
<head>
<script>
function getcheckboxes() {
var node_list = document.getElementsByTagName('input');
var checkboxes = [];
for (var i = 0; i < node_list.length; i++)
{
var node = node_list[i];
if (node.getAttribute('type') == 'checkbox')
{
checkboxes.push(node);
}
}
return checkboxes;
}
function toggle(source) {
checkboxes = getcheckboxes();
for(var i=0, n=checkboxes.length;i<n;i++)
{
checkboxes[i].checked = source.checked;
}
}
</script>
</head>
<body>
<form action="#" method="post">
<input type="checkbox" name="foo1" value="1"> 1<br/>
<input type="checkbox" name="foo2" value="2"> 2<br/>
<input type="checkbox" name="foo3" value="3"> 3<br/>
<input type="checkbox" name="foo4" value="4"> 4<br/>
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
<input type="submit" name="submit" value="Submit"/>
</form>
</body>
</html>
所以我想通过这个复选框选择一些id
2条答案
按热度按时间wdebmtf21#
sql in运算符in运算符允许您在where子句中指定多个值。in运算符是多个或多个条件的简写。
UPDATE***WHERE column_name IN (value1, value2, ...);
你可以看看这个。在这里puruo6ea2#
添加以下jqueryajax代码
在php端添加以下代码: