How do you use \'AND/OR\' in an if else PHP statement? Would it be:
1) AND
if ($status = \'clear\' AND $pRent == 0) {
mysql_query(\"UPDATE rent
A bit late but don't matter...
the question is "How do you use...?" short answer is you are doing it correct
&&
instead of AND
and ||
instead of OR
.
$a = 1
$b = 3
Now,
if ($a == 1 && $b == 1) { TRUE } else { FALSE }
in this case the result is "FALSE" because B is not 1, now what if
if ($a == 1 || $b == 1) { TRUE } else { FALSE }
This will return "TRUE" even if B still not the value we asking for, there is another way to return TRUE without the use of OR / || and that would be XOR
if ($a == 1 xor $b == 1) { TRUE } else { FALSE }
in this case we need only one of our variables to be true BUT NOT BOTH if both are TRUE the result would be FALSE.
I hope this helps...
more in:
http://www.php.net/manual/en/language.operators.logical.php
You have 2 issues here.
use ==
for comparison. You've used =
which is for assignment.
use &&
for "and" and ||
for "or". and
and or
will work but they are unconventional.
AND is &&
and OR is ||
like in C.
Yes. The answer is yes.
http://www.php.net/manual/en/language.operators.logical.php
Two things though:
&&
and ||
instead of and
and or
, but they work the same (safe for precedence).$status = 'clear'
should probably be $status == 'clear'
. =
is assignment, ==
is comparison.