$month = $_GET['month']; $year = $_GET['year']; class Calendar{ function Calendar() { } /* Get the array of strings used to label the days of the week. This array contains seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function getDayNames() { return $this->dayNames; } /* Set the array of strings used to label the days of the week. This array must contain seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function setDayNames($names) { $this->dayNames = $names; } /* Get the array of strings used to label the months of the year. This array contains twelve elements, one for each month of the year. The first entry in this array represents January. */ function getMonthNames() { return $this->monthNames; } /* Set the array of strings used to label the months of the year. This array must contain twelve elements, one for each month of the year. The first entry in this array represents January. */ function setMonthNames($names) { $this->monthNames = $names; } /* Gets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function getStartDay() { return $this->startDay; } /* Sets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function setStartDay($day) { $this->startDay = $day; } /* Gets the start month of the year. This is the month that appears first in the year view. January = 1. */ function getStartMonth() { return $this->startMonth; } /* Sets the start month of the year. This is the month that appears first in the year view. January = 1. */ function setStartMonth($month) { $this->startMonth = $month; } /* Return the URL to link to in order to display a calendar for a given month/year. You must override this method if you want to activate the "forward" and "back" feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. If the calendar is being displayed in "year" view, $month will be set to zero. */ function getCalendarLink($month, $year) { return ""; } /* Return the URL to link to for a given date. You must override this method if you want to activate the date linking feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. */ function getDateLink($day, $month, $year) { return ""; } /* Return the HTML for the current month */ function getCurrentMonthView() { $d = getdate(time()); return $this->getMonthView($d["mon"], $d["year"]); } /* Return the HTML for the current year */ function getCurrentYearView() { $d = getdate(time()); return $this->getYearView($d["year"]); } /* Return the HTML for a specified month */ function getMonthView($month, $year) { return $this->getMonthHTML($month, $year); } /* Return the HTML for a specified year */ function getYearView($year) { return $this->getYearHTML($year); } /* Calculate the number of days in a month, taking into account leap years. */ function getDaysInMonth($month, $year) { if ($month < 1 || $month > 12) { return 0; } $d = $this->daysInMonth[$month - 1]; if ($month == 2) { // Check for leap year // Forget the 4000 rule, I doubt I'll be around then... if ($year%4 == 0) { if ($year%100 == 0) { if ($year%400 == 0) { $d = 29; } } else { $d = 29; } } } return $d; } /* Generate the HTML for a given month */ function getMonthHTML($m, $y, $showYear = 1) { $s = ""; $a = $this->adjustDate($m, $y); $month = $a[0]; $year = $a[1]; $daysInMonth = $this->getDaysInMonth($month, $year); $date = getdate(mktime(12, 0, 0, $month, 1, $year)); $first = $date["wday"]; $monthName = $this->monthNames[$month - 1]; $prev = $this->adjustDate($month - 1, $year); $next = $this->adjustDate($month + 1, $year); $prevMonth = $this->getCalendarLink($prev[0], $prev[1]); $nextMonth = $this->getCalendarLink($next[0], $next[1]); $header = $monthName . (($showYear > 0) ? " " . $year : ""); $s .= "Previous Month"; $s .= "Next Month"; $s .= "
"; $s .= $this->dayNames[($this->startDay)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+1)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+2)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+3)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+4)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+5)%7]; $s .= " | \n"; $s .= ""; $s .= $this->dayNames[($this->startDay+6)%7]; $s .= " | \n"; $s .= "
---|---|---|---|---|---|---|
";
if ($d > 0 && $d <= $daysInMonth){
$link = $this->getDateLink($d, $month, $year);
$s .= (($link == "") ? $d : "$d");
} else {
$s .= " ";
}
//if ($month >= date("n")) {
if ($d>0) {
if ($month<10) {
$themonth = "0" . $month;
} else {
$themonth = $month;
}
if ($d<10) {
$thedate = "0" . $d;
} else {
$thedate = $d;
}
$comparedate = $year . "-" . $themonth . "-" . $thedate . " ";
$sql = "SELECT id,performer, DATE_FORMAT(datetime, '%l:%i%p') as eventtime FROM event WHERE approved=1 AND datetime LIKE '%$comparedate%' ORDER BY datetime ASC";
//print $sql . " "; $result = mysqli_query($sql,$mysql_dblink); while($row = mysqli_fetch_assoc($result)) { $eventid = $row[id]; $eventtime = $row[eventtime]; $performer = $row[performer]; $s .= " $eventtime\n"; $s .= "\n"; } } //} $s .= " | \n";
$d++;
}
$s .= "