我要做的是在表格中显示所有者数据,包括其成员。然而,有人的数据出现在另一行不应该出现的地方。这是我的成员表的表结构:
+-----------+---------+------------+
| unitMemId | ownerId | members |
+-----------+---------+------------+
| 1 | 1 | bato |
| 2 | 1 | manpacq |
| 3 | 1 | allan |
| 4 | 2 | hontiveros |
| 5 | 2 | kitty |
| 6 | 3 | jinky |
| 7 | 3 | sandara |
+-----------+---------+------------+
正如您所看到的,ownerid
列拥有数据bato
,manpacq
和allan
,但当它显示在表格中时,它显示如下:
First Name Middle Name Lastname Members Unit No. UnitSqmtrs
Rody Roa Duterte bato 205 150
Sarah Null Duterte manpacq 111 200
Manny Pacman Pacquiao allan 203 300
Titto Yow Sotto Hontiveros 404 5585
数据manpacq
和allan
会显示在行Sarah
中,当它出现在Rody
时,我尝试在我的表中添加一列,但同样的过程继续进行。这是我在html中的表格:
echo '<section class="">
<div class="container">
<table>
<thead>
<tr class="header">
<th>
First Name
<div>First Name</div>
</th>
<th>
Middle Name
<div>Middle Name</div>
</th>
<th>
Lastname
<div>Lastname</div>
</th>
<th>
Members
<div>Members</div>
</th>
<th>
Unit No.
<div>Unit No.</div>
</th>
<th>
Unit Squaremeters
<div>Unit Squaremeters</div>
</th>
</tr>
</thead>';
if ($result->num_rows > 0) {
// output data of each row
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['middlename'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['members'] . "</td>";
echo "<td>" . $row['unitNo'] . "</td>";
echo "<td>" . $row['squareMtrs'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
echo "</section>";
希望发布问题的结构可以接受。