gpt4 book ai didi

php - 在月份表中显示来自 mysql 的值

转载 作者:行者123 更新时间:2023-11-29 22:41:06 25 4
gpt4 key购买 nike

我需要根据一个月中的某一天显示 mysql 表中的值。我使用下面的代码显示月份的第 1-31 天,但如何将值插入到当天的确切单元格中?如何实现这一目标?

<?php
$conn=mysql_connect("....",".....","...");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("roomsbooking")) {
echo "Unable to select roomsbooking: " . mysql_error();
exit;
}
// get All the rooms with id_item = 1 (is room 201) and MAY.
$sql="SELECT * FROM bookings WHERE id_item = '1' AND month(the_date)='5'";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$room201 .= '<td>'.$row['id_state'].'</td>';
}
// get All the rooms with id_item = 2 (is room 104) and MAY.
$sql2 = "SELECT * FROM bookings WHERE id_item = '2' AND month(the_date)='5'";
$result2 = mysql_query($sql2);
while ($row = mysql_fetch_assoc($result2))
{
$Room104 .= '<td>'.$row['id_state'].'</td>';
}
echo '
<table class="">
<tfoot>
<th>Days</th>';
for($i = 1; $i <= 31; $i++) //statement to display month days.
{
echo "<th>" . $i . "</th>";
}
echo '</tfoot>
<tbody>
<tr>
<td><b>Room201:</b></td>'.$room201 .'
</tr>
<tr>
<td><b>Room104:</b></td>'.$Room104 .'
</tr>
</tbody>
</table>';
mysql_free_result($result);
?>

Present result Desirable

最佳答案

基于您的代码。请注意,有一些非常严重的事情应该做,但我没有解决,但我认为这会让您开始:http://pastebin.com/Fvs8A49n

关于php - 在月份表中显示来自 mysql 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29348092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com