IF In WHILE Not Working

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
asdfghjkl
Forum Newbie
Posts: 4
Joined: Tue Dec 01, 2009 2:03 pm

IF In WHILE Not Working

Post by asdfghjkl »

Code: Select all

while($row2 = mysql_fetch_array($res))
{
    $approved = $row2['approved'];
    $stuff = $row2['stuff'];
    if(approved=="0")
    {
    //Do nothing
    }
    else
    {
    echo $stuff;
    }
}
Why does the above code not work? In my table I have a column called approve that uses a tinyint and it's default value is 0 if it's changed to 1 I want to echo data. There is data in the table some with the value of 0 and others with the value 1 but it doesn't work at all. It should work.
AlanG
Forum Contributor
Posts: 136
Joined: Wed Jun 10, 2009 1:03 am

Re: IF In WHILE Not Working

Post by AlanG »

if($approved == "0") not if(approved == "0")

You should do the following and drop the else.

Code: Select all

 
if($approved != "0") {
    echo $stuff;
}
 
Post Reply