简体   繁体   中英

Multiple AND, OR statements

Hello I would like to know if the following code could be extended with another 'AND', 'OR' statement or does it need another 'IF' statement ?

if (in_array("juliette_geinformeerd", $opts)){
$where .= " AND juliette_geinformeerd = 1 ";
}

I tryed:

if (in_array("juliette_geinformeerd", $opts)){
$where .= " AND juliette_geinformeerd = 1 " . "OR juliette_geinformeerd = 2";
}

But that doesnt work.

//Update:

So this piece of code works toghether with AJAX. If you click the checkbox it updates the page and filters options. I would like to filter it on multiple statements instead of just 1 (yes or no).

    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";
        }

你应该使用$where .= " AND (juliette_geinformeerd = 1 " . "OR juliette_geinformeerd = 2)";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM