Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在月表中显示mysql中的值_Php_Mysql_Days - Fatal编程技术网

Php 在月表中显示mysql中的值

Php 在月表中显示mysql中的值,php,mysql,days,Php,Mysql,Days,我需要根据每个月的哪一天显示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

我需要根据每个月的哪一天显示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);
?>

基于您的代码。请注意,有一些非常严重的事情我没有提到,但我想这会让你开始:

那么,数据库中有当天的项目吗?你只要说选择,我们就看不到这个结构。我假设您希望将此项的值(可能称为day)与循环中的$I变量进行比较,如果它们匹配,则打印一些内容:有。该表有6列cust_id、id_item、姓氏、id_state、id_booking、id_date。id_state采用两个不同值“1”或“4”。请参见上面的图片。第一个图像会回送一行中的所有值,但我需要在一个月的确切日期回送它们。