我收到此错误:
解析错误:语法错误,意外'>'在 第40行的C:\ xampp \ htdocs \ jagan \ display.php
这是我的代码:
<html>
<head><title> Display Student Results </title></head>
<body>
<form action="display.php method="post">
<table>
<tr>
<td>Enter Hallticket Number:
<td><input type="number" name="hno">
</tr>
<tr>
<td><input type="submit" name="btnsearch" value="search">
</tr>
</table>
</form>
</body>
</html>
<?php
$conn=mysqli_connect("localhost","root","")or die("unable to connect");
mysqli_select_db($conn,"college");
if(isset($_POST['btnsearch']))
{
$hall=$_POST['hno'];
$result=mysqli_connect($conn,"select * from student where hno=$hall");
echo "<h1> Student Results </h1>";
echo "<table border=5>";
echo "<tr>";
echo "<th> hallticket";
echo "<th> Name";
echo "<th> class";
echo "<th> gst";
echo "<th> Tax";
echo "<th> php";
echo "<th> dmdw";
echo "<th> accounts";
echo "</tr>;
while($rows=mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".rows['hno'];
echo "<td>".rows['name'];
echo "<td>".rows['class'];
echo "<td>".rows['gst'];
echo "<td>".rows['tax'];
echo "<td>".rows['php'];
echo "<td>".rows['dmdw'];
echo "<td>".rows['acc'];
echo "</tr>";
}
echo "</table>";
}
?>
答案 0 :(得分:0)
你没有正确地调用mysql结果集,它&#34; row&#34;不是&#34;行&#34;。 Here are the docs
echo "<td>".rows['hno'];
应该是:
echo "<td>".row['hno'];
此外,您的HTML表格未正确形成。请查看this resource以了解如何创建表格。
您需要关闭<th>
和<td>
标签,如下所示:
echo "<th>Name</th>";
这是一个great tutorial,它将引导您完成PHP / MySQL编码。通过第一次工作将意味着更少的旅行到SO寻求帮助。