phpmysqlif-statementor-condition

how to write if condition for multpile queries like


I have 3 queries like

$q1 = select email from tbl students
$q2 = select email from tbl corporates
$q3 = select email from tbl institutes

i want check to all 3 tables if email count is zero from all above then only do proceed like that,, can i write like this:

if(mysqli_num_rows($q1) || mysqli_num_rows($q2)  || mysqli_num_rows($q3) ==0){
proceed to process. 
}else{
do nothing
}

My question is it a correct way to approach or anything is better left which i need to learn.


Solution

  • you need to use & instead of || and also check rows count for each of your mysql object

    if(mysqli_num_rows($q1) == 0 && mysqli_num_rows($q2) == 0 && mysqli_num_rows($q3) ==0){
        //proceed to process. 
    } else {
        //do nothing
    }