日期:2014-05-17 浏览次数:20743 次
//方法一
while($result=mysql_fetch_array($query)){
$bgcolor=($bgcolor=="blue") ? "white" : "blue";
echo "<tr bgcolor={$bgcolor}>";
echo "<td><a href=detail.php?gid={$result['gid']}>{$result['gname']}</a></td>";
echo "<td>{$result['endtime']}</td>";
echo "<td>{$result['current_price']}</td>";
echo "<td>{$result['reply_num']}</td>";
echo "</tr>";
}
//方法二
$flag=1;
while($result=mysql_fetch_array($query)){
if($flag % 2 == 0) $bgcolor="yellow";else $bgbolor="white"; //这种方式理论上可以阿
echo "<tr bgcolor={$bgcolor}>";
echo "<td><a href=detail.php?gid={$result['gid']}>{$result['gname']}</a></td>";
echo "<td>{$result['endtime']}</td>";
echo "<td>{$result['current_price']}</td>";
echo "<td>{$result['reply_num']}</td>";
echo "</tr>";
$flag++;
}