sql多个复选框或查询语句

时间:2013-02-17 01:28:32

标签: sql

如何在具有多个选择的查询中使用它,它必须类似于

SELECT * FROM venue_event where venue = $check or $check ??  

表格

 <form action="test.php" method="post">
 <input type="checkbox" name="check_list[]" value="value 1">
 <input type="submit" />
 </form>
 <?php
 if(!empty($_POST['check_list'])) {
 foreach($_POST['check_list'] as $check) {
        echo $check;
}
}
?>

1 个答案:

答案 0 :(得分:1)

我不太清楚php发布那个部分,但你的SQL查询应该看起来像:

SELECT *
FROM venue_event
WHERE venue IN ('venue1','venue2');

或者您可以使用OR:

SELECT *
FROM venue_event
WHERE venue = 'venue1' OR 
    venue = 'venue2';