Hello. I am making some final touches to thiis block I am working on and I am trying to get it where the rows alternate colors. For some reason though it only makes one big row and one color.
Any ideas?
<?
include("dbinfo2.inc.php");
$con = mysql_connect('localhost', $username, $password) or die('Unable to connect to localhost');
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM phpbb_topics ORDER BY topic_last_post_id DESC LIMIT 8";
$result=mysql_query($query);
$num=mysql_num_rows($result);
mysql_close();
$color1 = '#EEE8CD';
$color2 = '#F2F2F2';
// Define which color to use
$color = ($i%2 == 0 || $i == 0)? $color1:$color2;
// Basically, if $i/2 has no remainder, OR it $i is 0, make it color1, otherwise, color2
while ($row = mysql_fetch_array($result)) {
$topic_id = $row["topic_id"];
$topic_title = $row["topic_title"];
$topic_title = substr($topic_title, 0, 25);
?>
<tr style="background-color: <?php echo $color; ?>"><td>
<font class='contenttext'><? echo "<a href='".$forumroot."viewtopic.php?t=".$topic_id."'>$topic_title</a>$topic_time";?></font><br />
</td></tr>
<?
}
?>
-Thanks