I have this SQL table and I would like to display the data to html table like this:
I have this php code: My question is how can I do that all values with same post_id be in same row. The pictures are illustrations. Thank you for your help in advance!
<!DOCTYPE html>
<html>
<head>
<title>Booking</title>
<style>
table {
border-collapse: collapse;
width: 100%;
color: #588c7e;
font-family: monospace;
font-size: 25px;
text-align: left;
}
th {
background-color: #588c7e;
color: white;
}
tr:nth-child(even) {background-color: #f2f2f2}
</style>
</head>
<body>
<table>
<tr>
<th>Field14</th>
<th>Field15</th>
<th>Field16</th>
</tr>
<?php
$conn = mysqli_connect("localhost", "admin", "", "test");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT _field_14, _field_15, _field_16 FROM booking";
$result = $conn->query($sql);
?>
</table>
</body>
</html>