Bickey Posted January 31, 2011 Share Posted January 31, 2011 I'm confused... how do you say check if the field in MYSQL is blank? it's not getting what I'm attempting to get. Please help. I want to do actionA... if either of these 3 conditions are true tf1=="RED" tf1=="" tf2=="" AND tf=="apple" if(tf1=="RED" or tf1=="" or tf2=="" AND tf=="apple") { do actionA... } Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/ Share on other sites More sharing options...
Maq Posted January 31, 2011 Share Posted January 31, 2011 how do you say check if the field in MYSQL is blank? it's not getting what I'm attempting to get. Please help. How do you know? Did you output any of these variables to see what the actual value is? As far as your logic, I think you want: if((tf1=="RED" or tf1=="" or tf2=="") AND tf=="apple") Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/#findComment-1167996 Share on other sites More sharing options...
Bickey Posted January 31, 2011 Author Share Posted January 31, 2011 the variables output is correct. But I think my code is causing problems. when I test with the first 2 conditions it works but when I add the 3rd condition it doesn't give the desired output. ... in the 3rd condition I want check if tf2 is blank AND tf says apple (both should be true in the 3rd condition). Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/#findComment-1168001 Share on other sites More sharing options...
Maq Posted January 31, 2011 Share Posted January 31, 2011 the variables output is correct. But I think my code is causing problems. when I test with the first 2 conditions it works but when I add the 3rd condition it doesn't give the desired output. ... in the 3rd condition I want check if tf2 is blank AND tf says apple (both should be true in the 3rd condition). Then you have to group the logic together with parentheses: if(tf1=="RED" or tf1=="" or (tf2=="" AND tf=="apple")) Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/#findComment-1168015 Share on other sites More sharing options...
cyberRobot Posted January 31, 2011 Share Posted January 31, 2011 You just need to add the parenthsis around the last two conditions: <?php if($tf1=="RED" or $tf1=="" or ($tf2=="" and $tf=="apple")) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/#findComment-1168023 Share on other sites More sharing options...
Bickey Posted January 31, 2011 Author Share Posted January 31, 2011 Thanks you two! Quote Link to comment https://forums.phpfreaks.com/topic/226268-blank-field/#findComment-1168082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.