I made this code to extract data from mysql and bring the results on the page. The results that the code generated goes down the page. I would like them to be set side by side, may be 30 rows, then the next 30 rows. (After 3 columns of table,if there are still more data, they go on like this down the page if possible). I found a similar post about this, but since I am new to this,I couldn't apply the offered solution there to my code. Any help would be greatly appreciated. Thanks!
A simple illustration to show the solution I need:
<table class="result-table">
<tr>
<th>Week</th>
<th>Ball1</th>
<th>Ball2</th>
<th>Ball3</th>
<th>Ball4</th>
<th>Ball5</th>
<th>Ball6</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "db");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Week, Ball1, Ball2, Ball3, Ball4, Ball5, Ball6 FROM sample";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc())
{
echo "<tr><td>" . $row["Week"]."</td><td>" . $row["Ball1"] . "</td><td>"
. $row["Ball2"]. "</td><td>". $row["Ball3"]. "</td><td>". $row["Ball4"]. "</td><td>".$row["Ball5"]. "</td><td>". $row["Ball6"]. "</td></tr>";
}
echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>
</table>