为什么表字段不显示前三个字段的值?

时间:2018-03-07 12:03:04

标签: php html mysql database html-table

这是一些简短的表格代码。我在表格中使用了echo。

数据未打印为前三个字段。

ui-view

表输出图像

Table Output Image

1 个答案:

答案 0 :(得分:0)

您在每个动态数据中都错过了tr。更改您的代码如下:

echo "<table>";
    echo "<tr>
        <th>ID</th>
        <th>Date</th>
        <th>Reference</th>
        </tr>" ;
    while ($row = $result->fetch_object())
    {
        echo "<tr><td>" . $row->id . "</td>";
        echo "<td>" . $row->date . "</td>";
        echo "<td>" . $row->ref . "</td></tr>";
            }
    echo "  <tr>
        <th>First Name</th>
        <th>Father Name</th>
        <th>Phone</th>
        </tr>";
    while ($row = $result->fetch_object())
    {
    echo "<tr><td>" . $row->name . "</td>";
                    echo "<td>" . $row->fname . "</td>";
        echo "<td>" . $row->cell . "</td></tr>";
    }
    echo "<tr>
        <th>District</th>
        <th>Address</th>
        <th>Gender</th>
        </tr>";
    while ($row = $result->fetch_object())
    {
    echo "<tr><td>" . $row->district . "</td>";
            echo "<td>" . $row->address . "</td>";
    echo "<td>" . $row->gender . "</td></tr>";
    }
    echo "</table>";