Привет, у меня проблема с отображением даты зарезервированной комнаты в определенной колонке таблицы.таким образом, ожидаемый результат на первом изображении image1 , но я получаю результат на втором изображении imagw2 .Я прилагаю код ниже для помощи, пожалуйста.Я написал свой код с php, html и bootstrap.Я хочу получить результат, когда при загрузке страницы отображается зарезервированная дата данной комнаты в столбце, который соответствует дате, и если комната не зарезервирована, столбец остается пустым.
<!-- language: lang-php -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<?php
$con = mysqli_connect('localhost','root','','reservations');
$startingDay = date('Y-m-d', strtotime("first sunday of this month -6 days"));
$numberOfDays = 35;
$dates = array();
$weekCounter = 1;
$meetingRow = '';
$meetingRow .= '<div class="container">';
$meetingRow .= '<table class="table" border="1" cellpadding="2" cellspacing="2">';
$meetingRow .= '<tbody>';
for ($i = 0; $i <= $numberOfDays - 1; $i++) {
$date = date('m/j/Y', strtotime("$startingDay +$i days"));
$dates[] = $date;
if (date('l', strtotime($date)) == "Monday") {
$meetingRow .= '<tr><td colspan="8"></td></tr>';
$meetingRow .= '<tr>';
$meetingRow .= '<th>Week ' . $weekCounter++ . '</th>';
}
$meetingRow .= '<th>';
$meetingRow .= '<p>' . $date. '</p>';
$meetingRow .= '<p>' . date('l', strtotime($date)). '</p>';
$meetingRow .= '</th>';
if (date('l', strtotime($date)) == "Sunday") {
$meeting_room_sql = "SELECT id , meeting_room_name FROM meeting_room";
$meeting_room_result = mysqli_query($con, $meeting_room_sql);
// you are to use $meeting_room_result not $meeting_room_sql error occurs in fetching from meeting_room
while ($meeting_room_row = mysqli_fetch_assoc($meeting_room_result)) {
$meeting_room_id = $meeting_room_row['id'];
$meeting_room_name = $meeting_room_row['meeting_room_name'];
$meetingRow .= '<tr>
<td>
<div>' . htmlentities($meeting_room_name, ENT_QUOTES, "UTF-8") . '</div>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#meetingModal">Reserve</button>
</td>';
$reserved_sql = "SELECT meeting_room_id, reserved_date FROM meeting WHERE meeting_room_id = {$meeting_room_row["id"]}";
$reserved_result = mysqli_query($con, $reserved_sql);
$total_number_of_rows = 7;//As we have 7 days in a week so we have 7 days column
$RowCounter = 0;
while ($reserved_row = mysqli_fetch_assoc($reserved_result)) {
$RowCounter++;
$reserved_room_id = $reserved_row['meeting_room_id'];
$reserved_date = $reserved_row['reserved_date'];
if ($reserved_room_id == $meeting_room_id) {
$meetingRow .= '<td>' . htmlentities('Meeting Reserved ' . date('m/j/Y', strtotime($reserved_date)), ENT_QUOTES, "UTF-8"). '</td>';
} else {
$meetingRow .= '<td><br /></td>';
}
}
while ($RowCounter < $total_number_of_rows){
$meetingRow .= '<td><br /></td>';
$RowCounter++;
}
$meetingRow .= '<tr>';
}
$meetingRow .= '</tr>';
}
}
$meetingRow .= '</tbody>';
$meetingRow .= '</table>';
$meetingRow .= '</div>';
echo $meetingRow;
?>
</body>
</html>