Glese Posted November 30, 2011 Share Posted November 30, 2011 I have the following if statement: if ((isset($select_category) == 'All') || (!isset($select_category)) && (!isset($most_liked))) { The value for the variable gets taken from a drop down menu, which is a list of categories. The problem I am having is with the isset condition check is that the variable is always set, but it does not consider the check for equality with the 'All' condition. Which basically means no matter which category I choose from the drop down menu, it always goes to this very first if statement, and does NOT go to the other elseif statement, and I think it has to do with the isset condition check, because without it it would work, though without it I am getting a notice warning, that the variables are undefined. Any ideas how I can make it check if its equal to 'All' together with the isset condition check? What I am trying to say is no matter which category is chosen, with the isset condition check, the variable is always set, thus the if statement is true, there basically seems to be a contradiction going on. Quote Link to comment https://forums.phpfreaks.com/topic/252112-checking-a-variable-on-equality-with-an-isset-condition-check-wrapped-around/ Share on other sites More sharing options...
trq Posted November 30, 2011 Share Posted November 30, 2011 isset returns the bools either true or false, it will NEVER equal the string 'All'. if ((isset($select_category) && $select_category == 'All') || (!isset($select_category) && !isset($most_liked)) { Quote Link to comment https://forums.phpfreaks.com/topic/252112-checking-a-variable-on-equality-with-an-isset-condition-check-wrapped-around/#findComment-1292555 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.