table row alternating colors
Posted: Sun Oct 10, 2004 10:00 pm
i got this code out of a book to alternate the colors of the table rows
and i was wondering what it actually does? it seems like it does something like if $bg = dddddd then switch it to ffffff and vice versa. am i completely wrong about this?
Code: Select all
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$bg = ($bg=='dddddd' ? 'ffffff' : 'dddddd');
echo "<tr bgcolor="", $bg, "" ><td align="left">$row[0]</td><td align="left">$row[1]</td><td align="left">$row[2]</td><td align="left">$row[3]</td></tr>\n";
}