0
我希望有人能幫助,我有一個類訂票系統顯示的每週課程的健身房。它可以完美運行,但是幾周後,課程的某些細節會發生變化,可能是開始時間或教練。匹配數組一個日期在功能
目前的類是從數據庫中抽取並存儲在基於一週的一天,一個數組,然後一個功能比較日期,並將其顯示在正確的地方。
我有一個數據庫中的表上稱爲異常某一特定日期的任何變化的一類。
兩個陣列的結構是如下:
$timetable [Monday] [0] id, class_name, min_attendees, max_attendees, start_time, end_time, day, start_date, studio_name, firstname, surname
$exceptions [1] exc_class_id, exc_class_date, exc_name, exc_notes, exc_minattendees, exc_maxattendees, exc_price, exc_starttime, exc_endtime, exc_firstname, exc_surname, exc_studio_name
顯示在時間表中的類的功能如下:
function day_switch ($weekday, $timetable, $fulldate) {
switch($weekday)
{
case 'Monday':
foreach($timetable['Monday'] as $details) {
$date = date('Y-m-d',strtotime($weekday));
echo "<div class='class'>";
echo "<a href='" . "templates/viewClass.php?id=" . $details['id'] . "&date=" . $fulldate . "'>" . $details['class_name'] . "</a>";
echo '<br>';
echo $details['firstname'] . ' ' . $details['surname'];
echo '<br>';
echo $details['start_time'] . ' ' . $details['end_time'];
echo '<br>';
echo date('Y-m-d',strtotime($weekday)); // Replace this with number booked, need to join bookings onto timetable
echo "</div>";
}
break;
case 'Tuesday':
foreach($timetable['Tuesday'] as $details) {
$date = date('Y-m-d',strtotime($weekday));
echo "<div class='class'>";
echo "<a href='" . "templates/viewClass.php?id=" . $details['id'] . "&date=" . $fulldate . "'>" . $details['class_name'] . "</a>";
echo '<br>';
echo $details['firstname'] . ' ' . $details['surname'];
echo '<br>';
echo $details['start_time'] . ' ' . $details['end_time'];
echo '<br>';
echo date('Y-m-d',strtotime($weekday));
echo "</div>";
}
break;
等....
我需要將這個檢查看看異常數組並檢查類ID是否匹配,其次是當前日期匹配$ date。
在每個日期的例外中只有一條記錄,但每個類id可能有多個記錄,所以爲什麼SQL連接不起作用。
如果有人可以幫助我會非常感激!
非常感謝您花時間做到這一點,這是一個巨大的幫助!非常感謝!! – MKC