使用PHP显示Mysql数据给了我一个空白页面
我试图在php页面中显示一个包含数据库数据的表 没问题 当我尝试使用css使表格看起来更好时,浏览器只会给我一个空白页面。 这是我的密码。。。 如果我在打开表标记后删除id=csstest部分,一切正常,只要我添加id=csstest,我就会得到一个空白页。。。 我做错了什么使用PHP显示Mysql数据给了我一个空白页面,php,css,Php,Css,我试图在php页面中显示一个包含数据库数据的表 没问题 当我尝试使用css使表格看起来更好时,浏览器只会给我一个空白页面。 这是我的密码。。。 如果我在打开表标记后删除id=csstest部分,一切正常,只要我添加id=csstest,我就会得到一个空白页。。。 我做错了什么 <?php include 'config.php'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to
<?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>
更改以下语句:
echo "<table id="csstest"><tr>";
echo”“;
为此:
echo "<table id=\"csstest\"><tr>";
echo "<table id=\"csstest\"><tr>";
echo”“;
您需要在双引号前添加斜杠:
echo”“;
echo”“;
上面的代码生成解析错误,并且您的错误报告处于关闭状态,所以它只显示空白页面
试试下面的方法
echo "<table id='csstest'><tr>";
echo '<table id="csstest"><tr>';
echo "<table id=\"csstest\"><tr>";
echo”“;
回声';
回声“;
tryecho”“代码>非常感谢!如果你把它写成一个答案,我会选择它作为正确答案:)不,只要选择跳蛙就行了
echo "<table id='csstest'><tr>";
echo '<table id="csstest"><tr>';
echo "<table id=\"csstest\"><tr>";