PHP 表格不显示所有数据
我有一个表格,显示用户对产品撰写的评论。我遇到的问题是表格没有显示表格中的所有内容。换句话说,我想要显示的数据正在出现,但不是全部。
这是我的表的代码:
<?php
$result = mysql_query("SELECT * FROM reviews WHERE serial = '$id'")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'There Arent Any Reviews Yet';
} else {
echo "<table width=100% border='6'><tr><th>Comments/Thoughts</th><th>Ratings</th><th>Date</th><th>User</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $info['review']. "</td>";
echo "<td>" . $info['ratings']. " Stars</td>";
echo "<td>" . $info['date']. "</td>";
echo "<td>" . $info['user']. "</td>";
}
}
echo "</tr>";
echo "</table>";
?>
当用户输入评论时,表中仅显示几个单词。似乎可以显示多少书面评论是有限制的,但我不知道在哪里更改该值。
I have a table which displays reviews written by users about products. The problem I am having is that the table isn't showing everything in the table. In other words, the data I want displayed is coming up but not the whole amount.
This is the code for my table:
<?php
$result = mysql_query("SELECT * FROM reviews WHERE serial = '$id'")
or die(mysql_error()); ;
if (mysql_num_rows($result) == 0) {
echo 'There Arent Any Reviews Yet';
} else {
echo "<table width=100% border='6'><tr><th>Comments/Thoughts</th><th>Ratings</th><th>Date</th><th>User</th>";
while($info = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $info['review']. "</td>";
echo "<td>" . $info['ratings']. " Stars</td>";
echo "<td>" . $info['date']. "</td>";
echo "<td>" . $info['user']. "</td>";
}
}
echo "</tr>";
echo "</table>";
?>
when a user types in a review, only a few words in the table are shown. it seems like there is a limit to how much of the written review can be shown but i do not know where to change that value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 while 循环需要包含
标签(也称为表格行标签)才能正确形成表格。您还有一个格式错误的表头。
Your while loop needs to include
<tr>
tags (a.k.a table row tags) to correctly form the table. You also have a malformed table header.您的
位于错误的位置:
它看起来也没有在代码中的任何位置设置
$id
。尝试将其放在代码的顶部:Your
</tr>
is in the wrong place:It also looks like
$id
wasn't set anywhere in your code. Try putting this at the top of your code: