我是网络开发人员、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 文件写得很好,并且它使用了 .table
选择器。
那里有几个语法错误,都是因为你需要像这样转义内部 "
:
echo "A 'string with several \"nesting\" levels' needs escaping.";
关于php - 表格 html/CSS 输出错误 : unexpected T_STRING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6056207/