2014-04-06 142 views
1

我试图抓住我的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

标签(即行标签)也应该循环。 – vanion

+0

并在环路外取出''和''。 –

+0

谢谢大家修复它。对不起,延迟已经远离编码了一下。感谢你的帮助! – Ready

回答

1

所有TR标签是退出循环。

+0

doh!愚蠢的错误。感谢Benio,你真棒! – Ready

1

看来你需要启动

echo "<tr>"; 

和 结束与

echo "</tr>; 

现在你正在做这个while循环中只有一次