Sunday, 15 July 2012

session - php if statement with either OR is equal to -



session - php if statement with either OR is equal to -

i trying write if stement

if(($result["from_id"] or $result["to_id"]) == $_session['user_id']) { //do } else { // redirect }

is right way find out if either of 2 columns fetched row has same value of current registered session.

is possible?

if($result["from_id"] || $result["to_id"] == $_session['user_id']) { //do } else { // redirect }

no, in php have like:

if ( in_array( $_session['user_id'], array($result["from_id"], $result["to_id"]) ) )

or write separated comparisons every status (2 in case, in_array method scales bit better).

if results come mysql, can utilize in there straight well.

php session if-statement result

No comments:

Post a Comment