Issue with if statement...

Discussion in 'PHP' started by nickharper, Feb 6, 2009.

  1. #1
    I am trying to basically check 3 values and if they ALL the value "Not Available" then echo a cross, but otherwise echo a tick. I have the following code but it echos a cross even if the value is not "Not Available"

    if ($row_Allgames['systemlinkvs']=="Not Available" || $row_Allgames['systemlinkcoop']== "Not Available" || $row_Allgames['systemlinkcoopstory'] == "Not Available") 
    { echo '<a href="http://www.xbox360multiplayergames.com/games/'.$cTitle.'"><img src="http://www.xbox360multiplayergames.com/images/cross.gif" alt="'.$row_Allgames['Name'].' does not have System Link Capablities" title="'.$row_Allgames['Name'].' does not have System Link Capablities" border="0"/></a>'; }
    else
      echo '<a href="http://www.xbox360multiplayergames.com/games/'.$cTitle.'"><img src="http://www.xbox360multiplayergames.com/images/tick.gif" alt="'.$row_Allgames['Name'].' has System Link Capablities" title="'.$row_Allgames['Name'].' does have System Link Capablities" border="0"/></a>'
    PHP:
    I am lost :(
     
    nickharper, Feb 6, 2009 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Change || to and (&&)
     
    Danltn, Feb 6, 2009 IP
    nickharper likes this.
  3. InputProductions

    InputProductions Banned

    Messages:
    88
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try using a switch instead.
     
    InputProductions, Feb 6, 2009 IP
  4. Femto

    Femto Peon

    Messages:
    23
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ALL = And ( && )
    or = some one of them ( || )

    in your code you used " Or "
     
    Femto, Feb 6, 2009 IP
  5. InovvativeTech

    InovvativeTech Banned

    Messages:
    32
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here is he correct code

    
    if ($row_Allgames['systemlinkvs']=="Not Available" && $row_Allgames['systemlinkcoop']== "Not Available" &&  $row_Allgames['systemlinkcoopstory'] == "Not Available")
    { echo '<a href="http://www.xbox360multiplayergames.com/games/'.$cTitle.'"><img src="http://www.xbox360multiplayergames.com/images/cross.gif" alt="'.$row_Allgames['Name'].' does not have System Link Capablities" title="'.$row_Allgames['Name'].' does not have System Link Capablities" border="0"/></a>'; }
    else
      echo '<a href="http://www.xbox360multiplayergames.com/games/'.$cTitle.'"><img src="http://www.xbox360multiplayergames.com/images/tick.gif" alt="'.$row_Allgames['Name'].' has System Link Capablities" title="'.$row_Allgames['Name'].' does have System Link Capablities" border="0"/></a>'
    PHP:
     
    InovvativeTech, Feb 7, 2009 IP