Re: problem: if / == / !=

From: Date: Thu, 30 Nov 2000 11:00:37 +0000
Subject: Re: problem: if / == / !=
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-28009@lists.php.net to get a copy of this message
Thanks. Somehow it's still not there. When I alter the script and save it, the browser then displays correctly on the first call only. May be that I have things a bit mixed up with cookies and sess_variables, but I think not as when I echo $sess_usr[name] and $row[name] for every table row looped through, the values come out as expected. More help? - Magnus Daniel Convissor wrote: > > Magnus: > > > if (($write) && ($sess_usr[name] == $row[name])) > > > > { echo "<td><a > > ... snip .... > > edit</a></td>"; } > > > > elseif (($write) && ($sess_usr[name] != $row[name])) > > { echo "<td>&nbsp</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

« previous php.general (#28009) next »