codexx Posted June 16, 2007 Share Posted June 16, 2007 Hey Everyone, Does anyone have any recommendations or tips on where I can go to find a good scheduling script or a tutorial to make one? I'd perfer to make my own for security reasons so I know the code and for later addons. Basically I need to re-create something like http://radio.virtualdj.com/schedule/schedule.php where djs can login to book a time on the online radio and then it blocks the slot off. Thanks in Advance, Sean Quote Link to comment https://forums.phpfreaks.com/topic/55809-calender-scriptschedule/ Share on other sites More sharing options...
codexx Posted June 16, 2007 Author Share Posted June 16, 2007 I did some research on PHP Freaks for tutorials and found this wonderful one on Calender Events. Just wondering if anyone can help point me in the right direction as how I can modify this so it has the dates alone the top like the virtual dj one and then I can put all the times below? Script is.. function getEventDays($month, $year) { $days = array(); $sql = mysql_query("SELECT DAY(event_date) AS day, COUNT(event_id) FROM calendar_events WHERE MONTH(event_date) = '$month' AND YEAR(event_date) = '$year' GROUP BY day"); if (mysql_num_rows($sql) > 0) { while ($row = mysql_fetch_array($sql)) $days[] = $row['day']; } return $days; } function drawCalendar($month, $year) { // set variables we will need to help with layouts $first = mktime(0,0,0,$month,1,$year); // timestamp for first of the month $offset = date('w', $first); // what day of the week we start counting on $daysInMonth = date('t', $first); $monthName = date('F', $first); $weekDays = array('Su', 'M', 'Tu', 'W', 'Th', 'F', 'Sa'); $eventDays = getEventDays($month, $year); // Start drawing calendar $out = "<table id=\"myCalendar\">\n"; $out .= "<tr><th colspan=\"7\">$monthName $year</th></tr>\n"; $out .= "<tr>\n"; foreach ($weekDays as $wd) $out .= "<td class=\"weekDays\">$wd</td>\n"; $i = 0; for ($d = (1 - $offset); $d <= $daysInMonth; $d++) { if ($i % 7 == 0) $out .= "<tr>\n"; // Start new row if ($d < 1) $out .= "<td class=\"nonMonthDay\"> </td>\n"; else { if (in_array($d, $eventDays)) { $out .= "<td class=\"monthDay\">\n"; $out .= "<a href=\"?year=$year&month=$month&day=$d\">$d</a>\n"; $out .= "</td>\n"; } else $out .= "<td class=\"monthDay\">$d</td>\n"; } ++$i; // Increment position counter if ($i % 7 == 0) $out .= "</tr>\n"; // End row on the 7th day } // Round out last row if we don't have a full week if ($i % 7 != 0) { for ($j = 0; $j < (7 - ($i % 7)); $j++) { $out .= "<td class=\"nonMonthDay\"> </td>\n"; } $out .= "</tr>\n"; } $out .= "</table>\n"; return $out; } $year = isset($_GET['year']) ? $_GET['year'] : date('Y'); $month = isset($_GET['month']) ? $_GET['month'] : date('m'); echo drawCalendar($year, $month); // Previous month link $prevTS = strtotime("$year-$month-01 -1 month"); // timestamp of the first of last month $pMax = date('t', $prevTS); $pDay = ($day > $pMax) ? $pMax : $day; list($y, $m) = explode('-', date('Y-m', $prevTS)); echo "<p>\n"; echo "<a href=\"?year=$year&month=$m&day=$pDay\">« Prev</a> |\n"; // Next month link $nextTS = strtotime("$year-$month-01 +1 month"); $nMax = date('t', $nextTS); $nDay = ($day > $nMax) ? $nMax : $day; list($y, $m) = explode('-', date('Y-m', $nextTS)); echo "<a href=\"?year=$y&month=$m&day=$nDay\">Next »</a>\n"; echo "</p>\n"; // Calendar is done, let's list events for selected day $sql = mysql_query("SELECT * FROM calendar_events WHERE event_date = '$year-$month-$day'"); if (mysql_num_rows($sql) > 0) { while ($e = mysql_fetch_array($sql)) { echo "<p>$e[event_title]</p>\n"; } } else { echo "<p>No events today</p>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/55809-calender-scriptschedule/#findComment-275678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.