mforan Posted October 23, 2008 Share Posted October 23, 2008 how does one, make an IF ask an OR (||)?? god this is really hard to explain, basically im comparing 2 things, but i only want it to compare the second thing if the first thing is not allowed. in example: 2 users relating to 1 primary key. both users must be able to view it and their friends (some friends are with the primary key, some are not). but no one else lol. so basically, 2 groups. 1 piece of news, both accessable to the people the news happened on + the 2 groups, but no other groups. which is why i ask, is it possible to only do an OR|| if the previous value is false. Link to comment https://forums.phpfreaks.com/topic/129856-problem-i-cant-get-my-head-around/ Share on other sites More sharing options...
Barand Posted October 23, 2008 Share Posted October 23, 2008 Real-world examples often help with explanations Link to comment https://forums.phpfreaks.com/topic/129856-problem-i-cant-get-my-head-around/#findComment-673211 Share on other sites More sharing options...
Alt_F4 Posted October 23, 2008 Share Posted October 23, 2008 Not 100% on what you are asking here but: to use an OR in an IF statement -> if($check==1 || $test==2) this means that the statement will execute if either $check = 1 OR $test = 2 meaning that only 1 condition must be met. to use an AND in an IF statement -> if($check==1 && $test==2) this means that both conditions must be met for the statement to be executed I THINK what you want is some thing like this -> if($check != 1 && $test==2) I THINK... Link to comment https://forums.phpfreaks.com/topic/129856-problem-i-cant-get-my-head-around/#findComment-673220 Share on other sites More sharing options...
The Little Guy Posted October 23, 2008 Share Posted October 23, 2008 Like this? if(!$value){ // Not allowed if($value2){ // Do something } } Link to comment https://forums.phpfreaks.com/topic/129856-problem-i-cant-get-my-head-around/#findComment-673224 Share on other sites More sharing options...
mforan Posted October 23, 2008 Author Share Posted October 23, 2008 ive made it now so that: <?php if ((12 = 12) || (13 = 13)) { ?> page data <? } else { echo "error" this works, as everyone in both groups can read it, what i was ttrying to do was acheve the same thing without an else. lol. is that even possible? lmfao!? Link to comment https://forums.phpfreaks.com/topic/129856-problem-i-cant-get-my-head-around/#findComment-673232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.