我正在尝试编写一个非常基本的 PHP 脚本来从数据库中获取一些信息并将其输出到表中。这是我写的代码:
<html>
<head>
<title>FamInfo from dbCAN</title>
<meta name="description" content="Test PHP page">
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>
<h1>FamInfo from dbCAN</h1>
<table align="center" border="1" cellpadding="5">
<th>Family ID</th><th>Signature Domain</th><th>class</th><th>note</th><th>activity</th>
<?php
include '/vars.php'; // fixed, no change
$conn = mysql_connect($hostname,$username,$password);
$db_selected = mysql_select_db($db,$conn);
$result = mysql_query("select * from FamInfo",$conn);
while ($row = mysql_fetch_array($result))
{
echo '<tr>'; // terminates here, at the second quote
echo "<td>" . $row["FamID"] . "</td>";
echo "<td>" . $row["SigDomain"] . "</td>";
echo "<td>" . $row["class"] . "</td>";
echo "<td>" . $row["note"] . "</td>";
echo "<td>" . $row["activity"] . "</td>";
echo '</tr><br>';
}
mysql_close($conn);
?>
</table>
</body>
出于某种原因,PHP 似乎终止于我尝试回显表格行的行,这意味着我没有得到我需要的值。这是输出的图像:
有谁知道为什么会发生这种情况,或者潜在的解决方案是什么?谢谢您的意见!