我试图从我的MYSQL表中获取所有内容然后将其全部放入表中。出于某种原因,它将所有内容全部投入到一行中,而不是为更多数据创建新行。
我的代码在这里:
<?php
//DISPLAY CURRENT USERS ASC ON VIEW
$q="SELECT * FROM users ORDER BY id ASC";
$r=mysqli_query($dbc,$q);
?>
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">User Manager</div>
<div class="panel-body">
<p>Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</div>
<!-- Table -->
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>UserID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Status</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<?php echo "<tr>"; // Display Users onto table
while (($list= mysqli_fetch_assoc($r))){
echo"<td>".$list['id']."</td>";
echo"<td>".$list['fname']."</td>";
echo"<td>".$list['lname']."</td>";
echo"<td>".$list['email']."</td>";
echo"<td>".$list['status']."</td>";
echo"<td>".$list['role']."</td>";
}
echo"</tr>";?>
</tbody>
</table>
</div>
</div>
答案 0 :(得分:1)
所有TR
代码都不在循环中。
答案 1 :(得分:1)
在while循环中,您需要以
开头echo "<tr>";
和
结束echo "</tr>;
现在你只做了一次