PHP,HTML表创建

I have little problem with tables when u echo my results.

and this is my code

<?php
    //return data if any
    while ($client = mysqli_fetch_assoc($result)) {
        //output data form each client
        //var_dump($client);
?>
<table id="t01">
  <tr>
    <th>ID</th>
    <th>name</th> 
    <th>lastname</th>
    <th>age</th>
    <th>Username</th>
    <th>Password</th>
  </tr>
  <tr>
    <td><?php echo $client['id'] ?></td>
    <td><?php echo $client['emri'] ?></td> 
    <td><?php echo $client['mbiemri'] ?></td>
    <td><?php echo $client['mosha'] ?></td>
    <td><?php echo $client['username'] ?></td> 
    <td><?php echo $client['password'] ?></td>
  </tr>
  <style>
table {
    width:100%;
}
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
table#t01 tr:nth-child(even) {
    background-color: #eee;
}
table#t01 tr:nth-child(odd) {
   background-color:#fff;
}
table#t01 th  {
    background-color: black;
    color: white;
}
</style>
</table>

this is my code and the list its echo the first line like id, name ,lastname... for every result. so i want attributes on the top and then down results (i cant post a photo)

You just Need to reorder your code:

<table id="t01">
  <tr>
    <th>ID</th>
    <th>name</th> 
    <th>lastname</th>
    <th>age</th>
    <th>Username</th>
    <th>Password</th>
  </tr>

<?php
    //return data if any
    while ($client = mysqli_fetch_assoc($result)) {
        //output data form each client
        //var_dump($client);
?>
  <tr>
    <td><?php echo $client['id'] ?></td>
    <td><?php echo $client['emri'] ?></td> 
    <td><?php echo $client['mbiemri'] ?></td>
    <td><?php echo $client['mosha'] ?></td>
    <td><?php echo $client['username'] ?></td> 
    <td><?php echo $client['password'] ?></td>
  </tr>
><?php } ?>

</table>

You had Everything in youre While so for every Entry everything got printed.

And put your Style Tag in the Head Section of your HTML DOC