angelsRock Posted October 14, 2007 Share Posted October 14, 2007 why onlly one color appear? while ($Row = mysql_fetch_array ($Result)) { If ($color = "#FFFFDF") $color = "#DBFCFC"; else $color = "#FFFFDF"; $Row[selling_price]= number_format($Row[selling_price],2); print ("<TR ALIGN=center bgcolor=$color VALIGN=top>\n"); echo"<td align=center><a href='post-premiumreview.php?id=$Row[premPropertyID]'><font color='#3300CC'>".$Row[premPropertyID]."</font></a></td>"; print ("<TD ALIGN=center VALIGN=top>".$Row['type1']." </TD>\n"); print ("<TD ALIGN=center VALIGN=top>".$Row['state']." </TD>\n"); print ("<TD ALIGN=center VALIGN=top>".$Row['selling_price']."</TD>\n"); print ("<TD ALIGN=center VALIGN=top>".$Row['type3']."</TD>\n"); print ("<TD ALIGN=center VALIGN=top>".$Row['buildup_area']."</TD>\n"); print ("<TD ALIGN=center VALIGN=top>".$Row['datePosted']."</TD>\n"); print ("</TR>\n"); } Quote Link to comment https://forums.phpfreaks.com/topic/73181-solved-why-the-color-not-changing-alternately/ Share on other sites More sharing options...
Rithiur Posted October 14, 2007 Share Posted October 14, 2007 Replace: If ($color = "#FFFFDF") with: if ($color == "#FFFFDF") '=' is assigment operator, so currently your code simply always assigns the value "#FFFFDF" to $color, which then evaluates true (because the return value of assigment operator is the value assigned) and then the color is always assigned to "#DBFCFC". In other words, you should have been using == instead, because that's the actual comparison operator. Quote Link to comment https://forums.phpfreaks.com/topic/73181-solved-why-the-color-not-changing-alternately/#findComment-369152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.