Re: problem: if / == / !=
| From: | Daniel Convissor | Date: | Thu, 30 Nov 2000 02:07:51 +0000 |
| Subject: | Re: problem: if / == / != | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27954@lists.php.net to get a copy of this message | ||
Magnus:
> if (($write) && ($sess_usr[name] == $row[name]))
>
> { echo "<td><a
> ... snip ....
> edit</a></td>"; }
>
> elseif (($write) && ($sess_usr[name] != $row[name]))
> { echo "<td> </td>"; }
I think your problem may be you're calling the array incorrectly. The index
name is supposed to have quotes around them: $sess_usr['name'] and
$row['name'].
Also your code is evaluating up to four expressions. It's faster and cleaner
to do it like this, since there's only two expressions evaluated.
if ("$write") {
if ($sess_usr['name'] == $row['name']) {
... do stuff ...
} else {
... do other stuff ...
}
}
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409