0
I want to put an If with various conditions.
if ($row[??] != '' or NULL or 0000-00-00 )
Currently I have like this but I want to put two more Row. I have to create more if or I can add in that If?
0
I want to put an If with various conditions.
if ($row[??] != '' or NULL or 0000-00-00 )
Currently I have like this but I want to put two more Row. I have to create more if or I can add in that If?
6
The problem with your if
is that the or
are comparing nothing to nothing.
You need to compare again to something ($row[??]
in your case):
if ($row['xpto'] != '' and $row['xpto'] != NULL and $row['xpto'] != '0000-00-00' )
Improving your code, to check if the variable is empty (''
or NULL
), use the function empty
.
if (!empty($row['xpto']) and $row['xpto'] != '0000-00-00' )
PS.: Don’t forget the quotation marks on the date! ('0000-00-00'
)
PS2.: Analyzing better, how are you verifying what is different, so the correct operator to use is and
(or &&
)
It wants different from empty so it should use ! Empty
Obg. corrected.
Browser other questions tagged php if
You are not signed in. Login or sign up in order to post.
You really have to make a condition
x != y
for eachor
– Sergio
On the answers below, just watch out for the operators' precedence. There are differences between
and, or
and&&, ||
See test manual: http://php.net/manual/en/language.operators.precedence.php#117390– Daniel Omine