lawnmowerman
Banned
- Joined
- Aug 17, 2004
- Messages
- 11,073
- Reaction score
- 1,014
Ok man, here is my requirement, I have a simple database that consist of 9 rows, my goal is to create a table that is first display the first 3 numbers in a 3 row tables, then display a blank row. and continue fetching my 4th row from database and display it on the 5th row in html. and repeat the same procedures. how should i go about it?
the table should display like this.
but my code below is only display everything in one table without the blank row to seperate the rows in between.
@davidktw , can help me on this? thanks.
the table should display like this.
Data |
| ID | Number |
| 1 | xxxxx |
| 2 | xxxxx |
| 3 | xxxxx |
| 4 | xxxxx |
| 5 | xxxxx |
| 6 | xxxxx |
| 7 | xxxxx |
| 8 | xxxxx |
| 9 | xxxxx |
but my code below is only display everything in one table without the blank row to seperate the rows in between.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sample PHP Database Application</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
</head>
<body>
<?php
//Change the password to match your configuration
$link = mysqli_connect("localhost", "root", "", "123");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
echo "<br>";
$sql = "SELECT * FROM numbers";
$result = $link->query($sql);
echo "<div class='container'>";
echo "<div class='row-fluid'>";
echo "<div class='col-xs-6'>";
echo "<div class='table-responsive'>";
echo "<table class='table table-hover table-inverse'>";
echo "<tr>";
echo "<th>Data</th>";
echo "</tr>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>Number</th>";
echo "</tr>";
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["id"] . "</td>";
echo "<td>" . $row["number"] . "</td>";
echo "</tr>";
}
} else {
echo "0 results";
}
echo "</table>";
echo "</div>";
echo "</div>";
// Close connection
mysqli_close($link);
?>
</body>
</html>
@davidktw , can help me on this? thanks.
