Cores Alternadas

<? $con = mysql_connect("localhost","","") or die ("Erro na conexão"); $db = mysql_select_db("nomedodatabase",$con) or die ("Erro ao se conectar ao Database"); $sql = mysql_query("SELECT * FROM tb_estados",$con) or die ("Erro no SQL"); ?> <html> <head> <title>Coluna PHP / iMAsters</title> </head> <body bgcolor="#FFFFFF"> <table width=70% cellpading=0 cellspacing=1 align=center> <? for($i = 0;$i<mysql_num_rows($sql);$i++) { if(($i % 2) == 1) $fundo="#EBEBEB"; else $fundo="#CCCCCC"; ?> <tr> <td bgcolor="<?echo $fundo;?>"><div align=center><font face=Arial size=2> <?echo mysql_result($sql,$i,"estado");?></font></div></td> </tr> <? } ?> </table> </body> </html>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.