我正在尝试在 php 页面中显示包含来自我的数据库的数据的表。
完全没有问题。
当我尝试使用 css 使表格看起来更好时,浏览器只会给我一个空白页面。这是我的代码...如果我在打开表格标签后删除 id=csstest 部分,一切正常,只要我添加 id=csstest 我得到一个空白页...我做错了什么?
<?php
include 'config.php';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to db");
if (!mysql_select_db($database))
die("Can't select db");
// sending query
$result = mysql_query("SELECT data, cur_timestamp FROM {$table}");
if (!$result) {
die("Check your SQL query");
}
$fields_num = mysql_num_fields($result);
echo "<h1>Tabella: {$table}</h1>";
echo "<table id="csstest"><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
// printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
mysql_close($result);
?>
</table>