Mato
Mato

Reputation: 5

Check if information from database is blank

I need to check if status A and B is blank or 0, but my blank doesnt work, Any suggestions?

 $sta = db2_result($queryexe, 'STATUSA');
 $stb = db2_result($queryexe, 'STATUSB');


 if ($sta=="0" OR $sta=="" AND $stb=="0" OR $stb=="")

Upvotes: 0

Views: 37

Answers (2)

jiboulex
jiboulex

Reputation: 3031

You should use the empty function which consider 0, "0", null... as empty values :

if (empty($sta) && empty($stb)) {

If you want to stick with your logic, consider to separate the if statements in two parts :

if (
    ($sta=="0" OR $sta=="")
    AND
    ($stb=="0" OR $stb=="")
) {

Upvotes: 1

nospor
nospor

Reputation: 4220

if (($sta=="0" OR $sta=="") AND ($stb=="0" OR $stb==""))

2+3*4 is not the same as (2+3)*4. The same is with OR and AND

Upvotes: 0

Related Questions