Farbe ändern

Slater

Erfahrenes Mitglied
Hy, wie kann ich bei einer mysql abfrage bei der tabelle abwechselnd die Hintergrundfarbe ändern?

z.b

Weiss
Grau
Weiss
....

PHP:
$result = mysql_query($Anfrage,$Verbindung);
 while ($ausgabe = mysql_fetch_array ($result))
 {
 print ("
<table border=0>
<tr>
<td width=200 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Name]</font></td>
<td width=100 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Punkte]</font></td>
<td width=100 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Datum]</font></td>
</tr>
</table>
");
}

mfg Slater
 
PHP:
$zeile = 0;
$farbe1 = '#cccccc';
$farbe2 = '#000000';
$result = mysql_query($Anfrage,$Verbindung);
 while ($ausgabe = mysql_fetch_array ($result))
 {
$zeile++;
$hintergrundfarbe = ($zeile % 2) ? ($farbe1) : ($farbe2);
 print ("
<table border=0>
<tr>
<td bgcolor=$hintergrundfarbe width=200 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Name]</font></td>
<td bgcolor=$hintergrundfarbe width=100 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Punkte]</font></td>
<td bgcolor=$hintergrundfarbe width=100 height=20><font face=$fontface2 color=$fontcolor2 size=$fontsize2>$ausgabe[Datum]</font></td>
</tr>
</table>
");
}

Keine Gewähr, ist jetzt einfach nur so hingeschrieben ;)
 
Zurück