【发布时间】:2018-06-17 21:02:14
【问题描述】:
我以前做过这个,而且很有效。我试图在表中回显我的数据库中的特定行。这是我的代码:
<?php
$connect = mysql_connect("localhost", "xxx", "xxx") or
die ("Hey loser, check your server connection.");
mysql_select_db("xxx");
$quey1="select * from `Ad Requests`";
$result=mysql_query($quey1) or die(mysql_error());
?>
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Student Record</EM></caption>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Class</th>
</tr>
<?php
while($row=mysql_fetch_array($result)){
echo "</td><td>";
echo $row['id'];
echo "</td><td>";
echo $row['twitter'];
echo "</td><td>";
echo $row['why'];
echo "</td></tr>";
}
echo "</table>";
?>
它没有给我任何错误,但它只是显示一个没有这些行的空白表。
我的问题:为什么这不会显示表格中的任何行,我做错了什么?
【问题讨论】:
-
只是检查:你的意思是空白输出还是空白表?
-
我的意思是:prntscr.com/elbl7
-
您忘记为每个数据库行打开一个新的表行标签
tr。 -
检查 sql 是否正确,因为有时你会错过一些小事,然后它也没有显示输出并保持空白
标签: php mysql html-table