1 回答

TA贡献1725条经验 获得超8个赞
你可以这样做:
$query="SELECT * FROM table WHERE stuff = "otherstuff"";
$res=$conn->query($query);
while($row=$res->fetch_assoc()){
echo "<table>";
echo "<tr><th>".$row['date']."</th></tr>"; //here you get each date filtered by rows
echo "<tr>";
echo "<td>".$row['stuff']."</td>"; //data1
echo "</tr>";
echo "<tr>";
echo "<td>".$row['otherstuff']."</td>"; //data2
echo "</tr>";
echo "</table>";
}
在 html5 表中打印 myslq 查询的内容时,我建议使用 while() 而不是 foreach()。它遍历 while() 并为每一行生成一个表。
您的表格应如下所示:
Date Stuff Otherstuff Morestuff
Monday data1 data2 data3 //this one gets an own table
Tuesday XY XY XY //this one gets the next table
- 1 回答
- 0 关注
- 237 浏览
添加回答
举报