php - Html Table Error -


this codes shows title every line. mistake?

foreach($db->query('select * uyeler') $row) {              echo "<table>                     <tr>                     <th>id</th>                     <th>username</th>                     <th>sex</th>                     <th>country</th>                     <th>age</th>                     <th>twitter</th>                     <th>instagram</th>                     <th>snapchat</th>                     </tr>";              echo "<tr><td>" .$row['id'] . "</td>";             echo "<td>" .$row['username'] . "</td>";             echo "<td>" .$row['sex'] . "</td>";             echo "<td>" .$row['country'] . "</td>";             echo "<td>" .$row['age'] . "</td>";             echo "<td>" .$row['twitter'] . "</td>";             echo "<td>" .$row['instagram'] . "</td>";             echo "<td>" .$row['snapchat'] . "</td>";          echo "</tr></table>";         } 

the table seems this

id  username    sex country age twitter instagram   snapchat  1   canozpey    male    sadsad  0   twit    insta   snap  id  username    sex country age twitter instagram   snapchat  2   s   male    russia  12  test2   sad jgfhf  id  username    sex country age twitter instagram   snapchat  3   sda male    male    6   male    male    male  id  username    sex country age twitter instagram   snapchat  4   asd female  sadasd  0         id  username    sex country age twitter instagram   snapchat  5   adsafa  female  dassd   0            

you need put wrapping , header outside of loop - note looping on content don't include tags in foreach.

<table>   <tr>     <th>id</th>     <th>username</th>     <th>sex</th>     <th>country</th>     <th>age</th>     <th>twitter</th>     <th>instagram</th>     <th>snapchat</th> </tr>  <?php foreach($db->query('select * uyeler') $row) {         echo "<tr><td>" .$row['id'] . "</td>";         echo "<td>" .$row['username'] . "</td>";         echo "<td>" .$row['sex'] . "</td>";         echo "<td>" .$row['country'] . "</td>";         echo "<td>" .$row['age'] . "</td>";         echo "<td>" .$row['twitter'] . "</td>";         echo "<td>" .$row['instagram'] . "</td>";         echo "<td>" .$row['snapchat'] . "</td>";         echo "</tr>";     } ?>  </table> 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -