Jump to content

[SOLVED] why the color not changing alternately??


angelsRock

Recommended Posts

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"); 						
				} 				

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.