I'm trying to put a whole SQL database into html table. I'm using MySQLi API. But it just return the first row of the table , and the rest of them just look mess up.Here's my code:
<h1> School Lesson System</h1>
<?php
if(isset($_SESSION['u_id'])) {
echo "You are logged in
";
}
?>
<table border="1">
<thead>
<tr>
<td>Lesson_id</td>
<td>Teacher</td>
<td>Lesson</td>
<td>Day</td>
<td>Time</td>
<td>Classroom</td>
<td>Year</td>
<td>Curriculum</td>
</tr>
</thead>
<tbody>
<?php
require_once 'includes/dbh.inc.php';
$query = "SELECT * FROM monday";
$result = $conn->query($query);
$rows = $result->num_rows;
for ( $j = 0; $j < $rows; ++$j) {
$result->data_seek($j);
$row = $result->fetch_array(MYSQLI_ASSOC);
echo "<tr>";
echo "<td>" . $row['Lesson_id']. "</td>";
echo "<td>". $row['Teacher']. "</td>";
echo "<td>" .$row['Lesson']. "</td>";
echo "<td>" . $row['Day']. "</td>";
echo "<td>". $row['Time']. "</td>";
echo "<td>". $row['Classroom']. "</td>";
echo "<td>". $row['Year']. "</td>";
echo "<td>". $row['Curriculum']. "</td>";
echo "</tr>";
echo"</tbody>";
echo"</table>";
}
include_once 'footer.php';
?>
Any solution for this ????