...

View Full Version : Help needed - amending OR php logic to AND



jonnyi
11-14-2012, 04:39 PM
Hi -

I would like to amend the code here (https://github.com/soulseekah/Gravity-Forms-Conditional-Notifications/blob/master/gravityforms-conditional-notifications/gravityforms-conditional-notifications.php) so that instead of it saying "if radiobutton1= NO or radiobutton2 = NO or radiobutton3 = NO......etc.....then send this email message" it instead says "if radiobutton1 = NO and radiobutton2 = NO and radiobutton3 = NO....etc....then send email message 1, else send email message 2"

Can anyone help? I don't know php at all and need to do this as soon as possible, so any help would be gratefully received!

Custard7A
11-14-2012, 05:08 PM
What code do you have at the moment? You can basically write it like how you said it.





if($radiobutton1 == "NO" AND $radiobutton2 == "NO" AND $radiobutton3 == "NO")
{ /* All the radio-buttons are NO. */ }

elseif($radiobutton1 == "NO" OR $radiobutton2 == "NO" OR $radiobutton3 == "NO")
{ /* Some radio-buttons are NO. */ }

else{ /* No radio-buttons are NO. */ }



You can also write AND or OR in php like &&, or ||. These have higher precedence in some comparisons, but for a case like this it doesn't make a difference.

Edit: I just realized that your post had a link in it, CF links are so obscure. 500 lines of code, sheesh.. I don't have the time to go through and tell you what to change right now.

jonnyi
11-14-2012, 05:12 PM
What code do you have at the moment? You can basically write it like how you said it.





if($radiobutton1 == "NO" AND $radiobutton2 == "NO" AND $radiobutton3 == "NO")
{ /* All the radio-buttons are NO. */ }

elseif($radiobutton1 == "NO" OR $radiobutton2 == "NO" OR $radiobutton3 == "NO")
{ /* Some radio-buttons are NO. */ }

else{ /* No radio-buttons are NO. */ }



You can also write AND or OR in php like &&, or ||. These have higher precedence in some comparisons, but for a function like this it doesn't make a difference.

Hi - many thanks for the reply.

The link in my original post takes you to the Wordpress plugin code that I need to amend, so that's the only code I have if that helps? I believe the plugin owner said in reply to another person asking the same thing that it was the section after line 58 that would need to be changed.

As I'm no php programmer I'd be really grateful if you could help further and tell me what to change!

Thanks for any help you can give.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum