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 關注
- 212 瀏覽
添加回答
舉報