Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Help needed - amending OR php logic to AND

    Hi -

    I would like to amend the code here 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!

  • #2
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    What code do you have at the moment? You can basically write it like how you said it.

    PHP Code:


          
    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.
    Last edited by Custard7A; 11-14-2012 at 04:13 PM.

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Custard7A View Post
    What code do you have at the moment? You can basically write it like how you said it.

    PHP Code:


          
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •