i have a codeignter website where am displaying some values using foreach,i am trying to ignore specific values from database,
so i did the following code:
$res="select * from paymentform order by id desc limit 1000";
$query = $this->db->query($res);
foreach ($query->result_array() as $re) {
if($re['authstatus']!='success' || $re['authstatus']!='0300'){
................................
}
}
but the issue is still the columns containing success or 0300 is coming inside the foreach, can anyone please tell me what is wrong in here, thanks in advance
CodePudding user response:
change your if to this
if($re['authstatus']!='success' && $re['authstatus']!='0300')
CodePudding user response:
I think if you want to get all condition in your if statement, you must using '&&' not '||' We know that statement has different function, when you using || it will ignore some condition when there are 1 condition has true value. But, when you using && it will be checked one by one your condition untill all condition has true. Let's try implemented into your code from this ...
if($re['authstatus']!='success' || $re['authstatus']!='0300'){
................................
}
To this...
if($re['authstatus']!='success' && $re['authstatus']!='0300'){
................................
}
The meaning is, when $re['authstatus']!='success'
it will checked again another condition $re['authstatus']!='0300'