gznero gznero - 7 months ago 16
PHP Question

(PHP) If, Else not retrieve data in the condition properly

I have a problem of If-Else condition here. As the codes below,

if($status == 'New'){
$resultx0 = mysql_query("SELECT * FROM application_data_file WHERE Position_ID = '".$pos_id."' && Application_Status = 'New' OR 'Received' OR 'Checking' ");
}
elseif ($status == 'Not qualified'){
$resultx0 = mysql_query("SELECT * FROM application_data_file WHERE Position_ID = '".$pos_id."' && Application_Status = 'Failed' OR 'Not qualified' ");
}
elseif ($status == 'No Condition'){
$resultx0 = mysql_query("SELECT * FROM application_data_file WHERE Position_ID = '".$pos_id."' ");
}


The "New" and "Not qualified" conditions are go for only the first one in "application_data_file" table. "New" condition will retrieve only "New" but no "Received" or "Checking" as I input in the condition and "Not qualified" condition will retrieve only "Failed" without "Not qualified".

I have no idea about this. Is there anything wrong in the conditions?

Cheers.

Answer

Try like this

mysql_query("SELECT * FROM application_data_file 
             WHERE Position_ID = '".$pos_id."' 
             AND Application_Status IN ('New','Received','Checking')");