【发布时间】:2018-12-21 12:04:33
【问题描述】:
我正在尝试创建一个网站来显示预订系统的表格。
我在 mysql 数据库中有一个表,其中包含如下数据:
第二列是 post_id。预订详情使用相同的 post_id 提供。
我想创建一个 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>
【问题讨论】:
-
代码?你试过什么吗?
-
MySQL pivot table的可能重复
-
我知道,但是不运行 sql 查询就不可能吗?