View Full Version : PHP display dynamic data on table with alternating row colours

11-10-2010, 10:30 AM
Hi, I've been trying to display data called from a mysql database to a table with alternating row colors but without luck. A sample code of the same is shown below

<table width="100%" border="0">
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center">Release Date</div></td>
<td><div align="center">Change Status</div></td>
$now = mysql_query("SELECT * FROM table WHERE showing = '1' ORDER BY release_date DESC");
$nowCount = mysql_query("SELECT COUNT(*) AS now FROM table WHERE showing = '1'");
$numArr = mysql_fetch_array($nowCount);
$num = $numArr["now"];
echo $num." movies are currently listed as now showing.<br><br>";

while ($show = mysql_fetch_array($now)) {
$mov_id = $show["id"];
$mov_name = ucwords($show["name"]);
$thumb = SHOW_THUMBNAIL.''.$show["mini"];
$lnk = "<a href=\"?s=m&a=v&m=".$mov_id."\">".$mov_name."</a><br>";
$date = $show["date"];
if ($date != "-") {
$date = strftime("%b %d, 20%y", strtotime($date));
<td width="75px"><div align="center"><a href="?s=m&a=v&m=<?php echo $mov_id; ?>"><img src="<?php echo $thumb; ?>" title="<?php echo $mov_name; ?>" /></a></div></td>
<td><div align="center"><a href="?s=m&a=v&m=<?php echo $mov_id; ?>"><?php echo $mov_name; ?></a></div></td>
<td><div align="center"><?php echo $date; ?></div></td>
<td><div align="center">
<form id="change" name="change" method="post" action="">
<a href="?s=s&r=<?php echo $mov_id; ?>">Out of Theatres
<?php }?>

Any help will be appreciated.


11-10-2010, 12:49 PM
sorry, but where in this code snippet you are trying to change row color? Your <tr> has no styles or code

11-10-2010, 12:59 PM
while ($show = mysql_fetch_array($now)) {
<tr class="<?php echo ($i%2==0? 'even':'odd'); $i++;?>">

tr.even td{

tr.odd td{