【发布时间】:2013-01-03 16:12:32
【问题描述】:
我有一些这样的复选框
<form action="tt.php" method="post">
<input type="checkbox" name="lvl[]" value="0">0 
<input type="checkbox" name="lvl[]" value="1">1 
<input type="checkbox" name="lvl[]" value="2">2 
<input type="checkbox" name="lvl[]" value="3">3 
<input type="checkbox" name="lvl[]" value="4">4 
<input type="submit" value="Ok">
如何将选中的值添加到这样的 SQL 查询中?:
如果选中 2 和 4 则select name,lvl,team from $table where lvl=2 or lvl=4
如果选中 2 和 4 AND 0,则 select name,lvl,team from $table where lvl=2 or lvl=4 or team='abc'(如果选中 0,则 'select' 必须包含其中 team='abc' 的字符串,否则 - 不要)
如果没有选择则select name,lvl,team from $table
【问题讨论】: