Problem with simple if statement...

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
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Problem with simple if statement...

Post by orbdrums »

Hey all,

I can't seem to get this if statement to work. It will set the value in a style sheet to the screen output if the value returned from my table is "Y" or a different value if the table returns "N". The first record in my table has a value of "Y", however the if statement ALWAYS evaluates to "N". Here is the code:

while ($row = mysql_fetch_assoc($result))
{
if($r_n&1)
{
echo "<tr bgcolor=\"BDBDBD\">";
} else {
echo "<tr bgcolor=\"FBF8EF\">";
}
echo "<td><h5>",$r_n,"</h5></td>";
echo "<td><h5>",$row['member_id'],"</h5></td>";
echo "<td><h5>",$row['firstname']," ",$row['lastname'],"</h5></td>";
echo "<td align=\"left\"><h5>",$row['join_date'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['a_lo'],"</h5></td>";
$v_act = $row['act'];
if ($v_act = "Y")
{
$v_act_fc = "<h7>";
$v_act_fc_end = "</h7>";
}
if ($v_act = "N")
{
$v_act_fc = "<h3>";
$v_act_fc_end = "</h3>";
}
echo "<td align=\"center\">",$v_act_fc,$row['act'],$v_act_fc_end,"</td>";[/color][/color]
echo "<td align=\"center\"><h5>",$row['lck'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['lli_date'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['lli_time'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['llo_date'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['llo_time'],"</h5></td>";
echo "<td><h5>",$row['login'],"</h5></td>";
echo "<td><h5>",$row['email'],"</h5></td>";
echo "<td><h5>",$row['pers_img'],"</h5></td>";
echo "<td align=\"center\"><h5>",$row['img_date'],"</h5></td>";
echo "</tr>";
$r_n++;
}

Any help would be greatly appreciated.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Problem with simple if statement...

Post by twinedev »

common mistake when starting out (and where a good IDE will help detect it right away), you are ASSIGNING $v_act to be 'Y' (using =), not comparing it (using ==)
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Re: Problem with simple if statement...

Post by orbdrums »

Thanks so much. Worked like a charm.
Post Reply