目前我有一个相当简单的MySQL数据库。显然,每个记录中的每个字段都有一个名称。
然后我有一个小的PHP脚本来提供网页
<?php
include_once 'includes/dbh.inc.php';
?>
<! DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$sql="SELECT * FROM income_tax;";
$result=mysqli_query($conn,$sql);
$resultCheck=mysqli_num_rows($result);
if ($resultCheck>0) {
echo "<table border ='1')>";
echo "<tr>";
echo "<td>".Year."</td>";
echo "<td>".BRB."</td>";
echo "<td>".BR."</td>";
echo "<td>".HRB."</td>";
echo "<td>".HR."</td>";
echo "<td>".S_BR."</td>";
echo "</tr>";
while ($row=mysqli_fetch_assoc($result)){ // any way to simply rad through all fields?
echo "<tr>";
echo "<td>".$row['year']."</td>";
echo "<td>".$row['BRB']."</td>";
echo "<td>".$row['BR']."</td>";
echo "<td>".$row['HRB']."</td>";
echo "<td>".$row['HR']."</td>";
echo "<td>".$row['S_BR']."</td>";
echo "</tr>";
}
echo "</table>";
}
?>
</body>
</html>
数据库即将变得更大。我想做的是,而不是手动放入表中的标题行,是将字段的名称读入其中。由于我是php的新手,我不知道该怎么做。任何人都可以帮忙吗?
TIA