I'm trying to fetch mySQL data into html table with vertical header. My html table code is in the following code :
<table border="1" align="center">
<thead>
<tr>
<th>No.</th>
<?php
while ($row1 = mysqli_fetch_assoc($q)) {
echo "<td>$no</td>";
$no++;
}
?>
</tr>
<tr>
<th>Term</th>
<?php
while ($row2 = mysqli_fetch_assoc($q)) {
echo "<td>".$row2['term']."</td>";
}
?>
</tr>
<tr>
<th>Normalisasi TF.IDF</th>
<?php
while ($row3 = mysqli_fetch_assoc($q)) {
echo "<td>".$row3['tf_idf_normalisasi']."</td>";
}
?>
</tr>
</thead>
Here's screenshot of my table :

But mySQL data are not displayed on 2nd and 3rd <tr>. What is wrong with my code ? Can someone tell me how to make it work ? Thank you.