Page 1 of 1

SOLVED: if/else problem

Posted: Wed Mar 03, 2010 7:37 pm
by fbachofner
I'm iterating through a result set.

Within the display while loop I have a construct like this

Code: Select all

if ($row['Group_Show']='0')
    { echo '<td>NO</td>'; }
    else
    { echo '<td>YES</td>'; }
No matter what, "YES" is always echoed.

If I just

Code: Select all

echo $row['Group_Show'];
I get either 0 or 1 (corresponding to the data in the DB)

In the if/then construct I have tried:
  • $row['Group_Show']='0'
  • $row['Group_Show']="0"
  • $row['Group_Show']=0
notice the different quote options I've tried around the 0

I have also tried testing for "1" ( i.e. . . . if ($row['Group_Show']='1' ) and reversing the logic.

As I mentioned above, no matter what, "YES" is always echoed.

This must be something REALLY simple. ARGHH!

Thanks for any insight.

Re: if/else problem

Posted: Wed Mar 03, 2010 7:44 pm
by fbachofner
DOH!

I think I'm missing an "=" in the evaluation!

SOLVED Re: if/else problem

Posted: Wed Mar 03, 2010 7:45 pm
by fbachofner
good grief!

if ($row['Group_Show']='0')
needs to be
if ($row['Group_Show']=='0')

OF COURSE


sorry for wasting anyone's time!