You could try: [code] <?php $result = mysql_query("SELECT name FROM products"); $bg='#eeeeee'; // First row background color while($r=mysql_fetch_array($result); { $bg = ($bg == '#eeeeee') ? '#ffffff' : '#eeeeee'; // Shorthand if statement (if $bg equals #eeeeee, add #ffffff to $bg, else add #eeeeee) ?> <tr style="background-color:<?php echo $bg; ?>"> Data for the row... </tr> <?php } ?> [/code] That'll alternate your background colours between 2 different colours, but not more than that. One way of doing more than 2 could be to store the colours in an array and access them that way. Like this: [code] <?php $result = mysql_query("SELECT name FROM products"); $bg = array('#dasdas', '#bbbbbb', '#cccccc', '#dddddd', '#eeeeee', '#ffffff'); // Range of background colours in order to display $index = 0; // Which color in array to start at (0 being first one) while($r=mysql_fetch_array($result); { $index = ($index < count($bg)) ? $index + 1 : 0; ?> <tr style="background-color:<?php echo $bg[$index]; ?>"> Data for the row... </tr> <?php } ?> [/code] Both of these should work. Sorry if it's not very clear, let me know if it not working.