PHP查询到MYSQL,在何处没有其他可用选项

PHP查询到MYSQL,在何处没有其他可用选项,php,mysql,select,Php,Mysql,Select,我的脚本是为复选框答案准备的,但我也希望如果没有使用instruktor或instruktor_poczatkowy等的复选框,则选择整个列,如果选择某些选项,则只选择此选项 $dbr = dbq("SELECT * FROM `table` WHERE instruktor LIKE '%' OR instruktor in ('$instruktor1', '$instruktor2', '$instruktor3', '$instruktor4',

我的脚本是为复选框答案准备的,但我也希望如果没有使用instruktor或instruktor_poczatkowy等的复选框,则选择整个列,如果选择某些选项,则只选择此选项

$dbr = dbq("SELECT * FROM `table` WHERE instruktor LIKE '%' OR instruktor in ('$instruktor1', '$instruktor2', '$instruktor3', '$instruktor4',
                           '$instruktor5', '$instruktor6', '$instruktor7', '$instruktor8', '$instruktor9', '$instruktor10', '$instruktor11', '$instruktor12')
                            AND instruktor_poczatkowy in ('$instruktor_poczatkowy1', '$instruktor_poczatkowy2',
                           '$instruktor_poczatkowy3', '$instruktor_poczatkowy4', '$instruktor_poczatkowy5', '$instruktor_poczatkowy6',
                           '$instruktor_poczatkowy7', '$instruktor_poczatkowy8', '$instruktor_poczatkowy9', '$instruktor_poczatkowy10',
                           '$instruktor_poczatkowy11', '$instruktor_poczatkowy12') AND lokalizacja in ('$lokalizacja1','$lokalizacja2', '$lokalizacja3',  '$lokalizacja4', '$lokalizacja5')
                            AND status in ('$status1', '$status2', '$status3', '$status4')
AND chce_mail like '$chce_mail2' AND klub like '$klub2' order by nazwisko");
我希望它能像这样工作:

        $dbr = dbq("SELECT * FROM `table` WHERE instruktor LIKE '%' OR instruktor in ('$instruktor1', '$instruktor2', '$instruktor3', '$instruktor4',
                           '$instruktor5', '$instruktor6', '$instruktor7', '$instruktor8', '$instruktor9', '$instruktor10', '$instruktor11', '$instruktor12')
                           ELSE instruktor = % AND instruktor_poczatkowy in ('$instruktor_poczatkowy1', '$instruktor_poczatkowy2',
                           '$instruktor_poczatkowy3', '$instruktor_poczatkowy4', '$instruktor_poczatkowy5', '$instruktor_poczatkowy6',
                           '$instruktor_poczatkowy7', '$instruktor_poczatkowy8', '$instruktor_poczatkowy9', '$instruktor_poczatkowy10',
                           '$instruktor_poczatkowy11', '$instruktor_poczatkowy12') ELSE instruktor_poczatkowy = % AND lokalizacja in ('$lokalizacja1','$lokalizacja2', '$lokalizacja3',  '$lokalizacja4', '$lokalizacja5')
                           ELSE lokalizacja = % AND status in ('$status1', '$status2', '$status3', '$status4') ELSE status = %
AND chce_mail like '$chce_mail2' AND klub like '$klub2' order by nazwisko");
但别忘了怎么做。。。有人能给我一个建议吗

LIKE '%'
这意味着你的值可以是任何东西,这总是真的(除非你的值为空)

这意味着您的值正好是“foo”

LIKE '%foo'
这意味着您的价值以“foo”结尾

LIKE 'foo%'
LIKE '%foo%'
这意味着您的值以“foo”开头

LIKE 'foo%'
LIKE '%foo%'

这意味着您的值包含“foo”

为什么要这样使用
LIKE
,它只是说
LIKE
什么,这与不把它放在第一位是一样的。
chce\u邮件,比如“$chce\u mail2”和klub邮件,比如“$klub2”
应该是
chce\u邮件,比如“%$chce\u mail2%”和klub邮件,比如“%$klub2%”
这样是有效的,但在我的另一个例子中,在我测试“ELSE”的时候,这样的代码总是告诉我一切。。。无论是否选中sobe复选框…我如何才能在没有LIKE的情况下选择all?请记住,默认情况下MySQL模式匹配不区分大小写。我希望将此LIKE用作select all。以及如何在该查询中写入:如果在我的表中(“$status1”、“$status2”、“$status3”、“$status4”)中的状态未被选中,而不是“全选”状态,则转到“检查”复选框中的更多数据未被选中。如果要在a、b、c、d、e均为真时选择行,请使用OR运算符。@eggyal,是的,是的。如果他/她想要不区分大小写的行为,那么确实需要适当的函数。但是,当我使用“或instruktor LIKE='%'”在其他情况下“或instruktor!=0”后,它将始终向我显示第二个选项,忽略此“instruktor in($instruktor1'、'$instruktor2'、'$instruktor3'”,还有其他方法吗?