您好我想知道以下代码是否可以使用另一个'AND','OR'语句进行扩展,还是需要另一个'IF'语句?
if (in_array("juliette_geinformeerd", $opts)){
$where .= " AND juliette_geinformeerd = 1 ";
}
我试过:
if (in_array("juliette_geinformeerd", $opts)){
$where .= " AND juliette_geinformeerd = 1 " . "OR juliette_geinformeerd = 2";
}
但那不起作用。
//更新:
所以这段代码与AJAX一起工作。如果单击该复选框,则会更新页面并过滤选项。我想在多个语句上过滤它而不只是1(是或否)。
答案 0 :(得分:3)
if (in_array("juliette_geinformeerd", $opts)){
$where .= " juliette_geinformeerd = 1 " . "OR juliette_geinformeerd = 2";
}
// if there is a no other conditions in the where if there any condition so try to write like that:
$where .="('juliette_geinformeerd_else = 1";
if (in_array("juliette_geinformeerd", $opts)){
$where .= "and juliette_geinformeerd = 1) " . "OR juliette_geinformeerd = 2";
}
答案 1 :(得分:0)
您应该使用$where .= " AND (juliette_geinformeerd = 1 " . "OR juliette_geinformeerd = 2)";