Alternating Table Colour
Posted: Thu Oct 23, 2003 8:12 pm
Hi I would like to have an alternating BG colour for the table created by this code, or is this done somehow in MySQL (newbie) Any help you can provide would be amazing. Thanks. javascript:emoticon(':)')
Code: Select all
<?php
// Connect To SQL Server
$connection = mysql_connect("localhost","x","x") or die ("Could Not Connect To Required Server");
// Select Database
$select_db = mysql_select_db("database") or die ("Could Not Connect To Required Database");
// Set Query As Vaiable
$result = mysql_query("SELECT * FROM test_table ORDER BY first_name, last_name");
// Show Table Headers
echo "\n<center><table class='body' border='0' width='100%'>";
echo "\n<tr>".
"\n\t<th><div align=center></div></th>".
"\n\t<th><div align=center>In/Out</div></th>".
"\n\t<th><div align=left>Name</div></th>".
"\n\t<th><div align=left>Ext</div></th>".
"\n\t<th><div align=left>Department</div></th>".
"\n\t<th><div align=left>Alt Phone</div></th>".
"\n\t<th><div align=left>Email</div></th>".
"\n</tr>";
// Fetch Query Variable & Start Output In Table
while ($row = @ mysql_fetch_array($result))
{
echo "\n<tr>" .
"\n\t<td><a href=actions/toggle_status.php?carbonite_id={$row["carbonite_id"]}&in_out={$row["in_out"]}><center>Toggle</center></a>".
"\n\t<td><center><b>{$row["in_out"]}</b></center></td>".
"\n\t<td>{$row["first_name"]}\n\t {$row["last_name"]}</td>" .
"\n\t<td>{$row["extension"]}</td>" .
"\n\t<td>{$row["designation"]}</td>".
"\n\t<td>{$row["alt_phone"]}</td>".
"\n\t<td><a href=mailto:{$row["email"]}>{$row["email"]}</a></td>" ;
}
// End Table
echo "\n</table></center>";
// Get # Of Table Rows & Output
$num_carbonites = mysql_num_rows($result);
echo "\n<center><P class=body>Number Of Listed Carbon Staff Members: <b>$num_carbonites</b></p></center>";
//Kill Connection
mysql_close($connection);
?>