php - Confusing IF clauses -
i'm making search engine, , i've made query put different types of search want (e.g. username, city, age etc.). i've come part have if statements output correct results, reason can't figure out how selects if statement i'd want to.
the script echoes out block of if has been executed debugging, , says "age" block executed instead of "county" want. here's code, , record; normal , age ifs work fine, suspect syntax error can't see. doing wrong logic wise?
first if
if(($searchfromage == null || $searchfromage == "nooption") && ($searchtoage == null || $searchtoage == "nooption") && ($searchcounty == null || $searchcounty == "nooption") && ($searchcity == null || $searchcity == "by")){ echo "normal"; }
age if
elseif(($searchfromage != null || $searchfromage != "nooption") && ($searchtoage != null || $searchtoage != "nooption")){ echo "age"; }
county if
} elseif($searchcounty != null || $searchcounty != "nooption"){ echo "county"; }
script output: age
$searchfromage != null || $searchfromage != "nooption"
this condition true if $searchfromage == "nooption" because != null.
tou need make changes in condition.
use ($searchfromage != null && $searchfromage != "nooption")
in if condition.
it same conditions. use &&
instead of ||
Comments
Post a Comment