0
我有一個在線mysql預訂系統數據庫,我試圖用this tutorial鏈接到一個可視php日曆。檢查MySQL表中的任何記錄是否存在於特定日期
每天在日曆上由<td>
表示,我使用以下PDO查詢來確定每天的背景顏色(如果可用=無顏色,如果不是紅色)。
的一個併發症,我已經是,我需要在視覺上顯示1個預訂結束一天X,並顯示另一個預訂開始在同一天十
$query_params = array(
':campervan_id' => $_GET['campervan'],
':day' => $date_form.($i - $startday + 1)
);
$query = "
SELECT
car,
booking_id,
DATE_FORMAT(start_date, '%e/%c') AS s_d,
DATE_FORMAT(end_date, '%e/%c') AS e_d
FROM
bookings as bb
INNER JOIN
reservation as br ON bb.booking_id=br.bookings_id
INNER JOIN
cars as bc ON br.car_id=bc.car_id
WHERE
bc.campervan_id=:campervan_id AND
:day BETWEEN bb.start_date AND bb.end_date
";
與當時我使用下列到輸出表格單元格的結果:
if($i < $startday) {
echo "
<td>
</td>
";
}
else {
// IF DAY IS AVAILABLE
if(!$rows) {
$color = "none";
}
// IF DAY IS UNAVAILABLE
else {
$color = "#F3747F";
}
$dayMonth = ($i-$startday + 1)."/$cMonth";
// If DAY FALLS ON A START PICK UP DATE
if ($dayMonth == $rows['s_d']) {
$back = "background-image:url(\"images/morning_back.png\");";
$color = "none";
}
// If DAY FALLS ON A END DROP OFF DATE
else if($dayMonth == $rows['e_d']) {
$back = "background-image:url(\"images/afternoon_back.png\");";
$color = "none";
}
// **************************************************
// IF FALLS ON BOTH A START AND END DATE????????
else if($dayMonth == ($rows['s_d'] && $rows['e_d'])) {
$back = "background-image:url(\"images/full_back.png\");";
$color = "none";
}
// **************************************************
else {
$back = "";
}
echo "
<td align='center' valign='middle' height='100px' width='134' style='color:#FFFFFF; background-color:".$color."; ".$back." border:1px solid white;'>
".($i-$startday + 1)."
</td>
";
}
這適用於視覺顯示上的每個預訂,對於每一個結束日期的開始日期對角線分割的背景圖像,但我不能讓天那裏既是一個結束預訂和另一個的開始顯示正確。
我認爲這是因爲我最初的查詢只查看一個預訂記錄 - 我需要它來識別所有這些記錄,任何人都可以幫忙嗎?
這是我需要的,謝謝! – 2013-03-13 11:03:28