SOLVED: if/else problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fbachofner
Forum Newbie
Posts: 18
Joined: Sun Feb 28, 2010 6:29 am

SOLVED: if/else problem

Post 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.
Last edited by fbachofner on Wed Mar 03, 2010 7:53 pm, edited 1 time in total.
fbachofner
Forum Newbie
Posts: 18
Joined: Sun Feb 28, 2010 6:29 am

Re: if/else problem

Post by fbachofner »

DOH!

I think I'm missing an "=" in the evaluation!
fbachofner
Forum Newbie
Posts: 18
Joined: Sun Feb 28, 2010 6:29 am

SOLVED Re: if/else problem

Post 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!
Post Reply