菜鸟问题,这么不能都在表里显示记录!
<?php
    include("conn.php");
    $sql="SELECT * FROM login";
      $query=mysql_query($sql);
      ?>      <table border=1  width=500 cellpadding="5" cellspacing="1" bgcolor="#add3ef">
    <caption align=center>注册记录</caption>   <tr>
      <th align="center">ID</th>
      <th align="center">昵称</th>
      <th align="center">密码</th>
      <th align="center">邮箱</th>
      <th align="center">性别</th>
    </tr>
      <?php
     while($row=mysql_fetch_array($query))
     {
?>      <tr>
      <td align="center"><?php echo $row['id']; ?></td>
      <td align="center"><?php echo $row['user']; ?></td>
      <td align="center"><?php echo $row['pwd'];?></td>
      <td align="center"><?php echo $row['email']; ?></td>
      <td align="center"><?php echo $row['sex']; ?></td>
      </tr>
      <br>
</table>
    <?php
     }
    ?>我想把所有的记录都在一个表中显示,为什么只有第一条记录在表中显示,该怎么改啊!!

解决方案 »

  1.   


    <?php
    $conn = mysql_connect("localhost","root","123");
    mysql_select_db("csdn");
    mysql_query("set names gbk");
    $sql="SELECT * FROM login";
    $query=mysql_query($sql,$conn);
    ?><table border=1 width=500 cellpadding="5" cellspacing="1"
    bgcolor="#add3ef">
    <caption>注册记录</caption>
    <tr>
    <th align="center">ID</th>
    <th align="center">昵称</th>
    <th align="center">密码</th>
    <th align="center">邮箱</th>
    <th align="center">性别</th>
    </tr> <?php
    while($row=mysql_fetch_array($query))
    {
    ?> <tr>
    <td align="center"><?php echo $row['id']; ?></td>
    <td align="center"><?php echo $row['user']; ?></td>
    <td align="center"><?php echo $row['pwd'];?></td>
    <td align="center"><?php echo $row['email']; ?></td>
    <td align="center"><?php echo $row['sex']; ?></td>
    </tr>
    <?php
    }
    ?>
    </table>
      

  2.   

    楼上正解,你table的关闭符不应该放在while循环里面