PHP:为什么在第 38 行出现语法错误、意外的“结束时”(T_ENDWHILE)?我第一次尝试使用 php 和 mysql 创建一个论坛,但我不确定我的代码有什么问题。
<?php
session_start();
require"db_connect.php";
$sql = "SELECT forum_id, forum_name FROM forum_tbl";
if ($query = $db->prepare($sql)){
$query->bind_result($f_id, $f_name);
$query->execute();
$query->store_result();
}else{
echo $db->error;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Forum</title>
<meta/>
<style type="text/css">
</style>
</head>
<body>
<div class="container">
<div class="content">
<table align="center" width="80%">
<?php
if($query->num_rows !==0)
while($row = $query->fetch())
?>
<tr>
<td><a href="forum.php?id=<?php echo $f_id?>"><?php echo $f_name;?> </a></td>
</tr>
<?php endwhile; endif;?>
</table>
</div>
</div>
</body>
</html>