Page 1 of 1

IF In WHILE Not Working

Posted: Wed Dec 02, 2009 5:16 pm
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.

Re: IF In WHILE Not Working

Posted: Wed Dec 02, 2009 7:50 pm
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;
}