文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>交替颜色显示Mysql的记录

交替颜色显示Mysql的记录

时间:2007-02-17  来源:PHP爱好者

<?

$connection = mysql_connect("hostname","username","password");

$db = mysql_select_db("db_name", $connection);

$sql = mysql_query("SELECT * FROM table_name ORDER BY field1 ASC");

echo "<table cellpadding=0 cellspacing=0 border=0><tr><td><b>Field1</b></td><td><b>Field2</b></td><td><b>Field3</b></td></tr>";

$alternate = "2";

while ($row = mysql_fetch_array($sql)) {

$field1 = $row["field1"];

$field2 = $row["field2"];

$field3 = $row["field3"];

if ($alternate == "1") {

$color = "#ffffff";

$alternate = "2";

}

else {

$color = "#c0c0c0";

$alternate = "1";

}

echo "<tr bgcolor=$color><td>$field1</td><td>$field2</td><td>$field3</td></tr>";

}

echo "</table>";

?>
php爱好者站 http://www.phpfans.net php动态|php基础|php进阶|php模板.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载