简体   繁体   English

PHP表未显示所有数据

[英]PHP Table Does Not Display All Data

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. 似乎可以显示多少书面评论有一定的限制,但我不知道在哪里可以更改该值。

Your </tr> is in the wrong place: 您的</tr>放在错误的位置:

    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>";
?>

It also looks like $id wasn't set anywhere in your code. 看起来$id并未在代码中的任何地方设置。 Try putting this at the top of your code: 尝试将其放在代码的顶部:

$id = mysql_real_escape_string($_GET['id']);

Your while loop needs to include <tr> tags (aka table row tags) to correctly form the table. 您的while循环需要包含<tr>标记(也称为表行标记)以正确形成表格。 You also have a malformed table header. 您还具有格式错误的表头。

echo "<table width=100% border='6'>
          <tr> 
              <th>Comments/Thoughts</th>
              <th>Ratings</th>
              <th>Date</th>
              <th>User</th>
          </tr>"; // Missing TR here also!!
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>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM