okay..I've figured out how to do alternating colors, but the tables stretch based on who types the longest sentence, and it makes the usernames go to double lines instead of one line. Is there a way to define the tables so that they are set to a certain length?
Example:
Username...... Time..... Message.............................................................
Also....in my code, it's giving me 2:00am for every post....it never changes....
Anyone got any ideas? Thank you:
CODE:
Code:
<?php
require_once 'cn.php';
require_once 'protect.php';
$fiveMinutesAgo = time() - 600;
$sql = 'SELECT
username, message_content, message_time
FROM
messages
WHERE
message_time > ' . $fiveMinutesAgo . '
ORDER BY
message_time';
$result = mysql_query($sql, $cn) or
die(mysql_error($cn));
$color="1";
echo '<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0">';
while($rows=mysql_fetch_array($result)){
$hoursAndMinutes = date('g:ia', $row['message_time']);
if($color==1){
echo "<tr bgcolor='#CCCCFF'>
<td>".$rows['username']."</td><td>".$hoursAndMinutes."</td><td>".$rows['message_content']."</td>
</tr>";
$color="2";
}
else {
echo "<tr bgcolor='#DFDFDF'>
<td>".$rows['username']."</td><td>".$hoursAndMinutes."</td><td>".$rows['message_content']."</td>
</tr>";
$color="1";
}
}
echo '</table>';
mysql_close();
?>