【发布时间】:2011-08-28 17:04:24
【问题描述】:
我是 web 开发、PHP、CSS 和 html 的新手。我想在我的表中放置一个 CSS 来显示我的数据库中的数据,但它不起作用。
这是我的代码:
我的 CSS 文件名为“table.css”...
<html>
<head>
<title>WEW</title>
<head>
<link href="table.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$con = mysql_connect("localhost","abc123","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database_ME", $con);
$result = mysql_query("SELECT * FROM id");
$data->set_css_class("table");
echo "<table class="table">
<tr>
<th>id</th>
<th>password</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
mysql_close($con);
?>
</body>
</html>
【问题讨论】:
-
发布你的 css 问题也不完整
-
阅读有关字符串和引号的手册php.net/manual/en/language.types.string.php。
-
你需要转义引号 echo "
etc ..
标签: php css mysql html-table