Code: calendar.php
\'; echo \'

\', $month_title[--$month], \'

\'; for ( $x = 0; $x < 7; $x++ ) echo \'\', $week_titles[ $x ], \'\'; /* ensure that a number of blanks are put in so that the first day of the month lines up with the proper day of the week */ $offset = date( \"w\", \"U\" ); echo \'\'; if ( $offset > 0 ) echo str_repeat( \" \", $offset ); /* start entering in the information */ require(\"$DOCUMENT_ROOT/../dbconnect.inc\"); /* connect to MySQL database */ $currmonth = $month_title[$month]; for ( $day = 1; $day <= $totaldays; $day++ ) { $query = \"select * from \".$currmonth.\" where date = \".$day; $result = mysql_query($query); $num_results = mysql_num_rows($result); if ( $day == date(\"j\") ) /* check if this is today, highlight box */ { echo \'
\'.$day.\'
\'; for ($i=0;$i<$num_results;$i++) { $row = mysql_fetch_array($result); echo \'\'.$row[\"weyr\"].\'
\'.$row[\"wen\"]; echo \'\\\', LEFT)\" onMouseOut=\"nd()\">\'; echo htmlspecialchars( stripslashes($row[\"who\"])).\'

\'; } echo \'\'; $offset++; } else { echo \'
\', $day, \'
\'; for ($i=0;$i<$num_results;$i++) { $row = mysql_fetch_array($result); echo \'\'.$row[\"weyr\"].\'
\'.$row[\"wen\"]; echo \'\\\', LEFT)\" onMouseOut=\"nd()\">\'; echo htmlspecialchars( stripslashes($row[\"who\"])).\'

\'; } echo \'\'; $offset++; } /* if we\'re on the last day of the week, wrap to the other side */ if ( $offset > 6 ) { $offset = 0; echo \'\'; if ( $day < $totaldays ) echo \'\'; } } /* fill in the remaining spaces for the end of the month, just to make it look pretty */ if ( $offset > 0 ) $offset = 7 - $offset; if ( $offset > 0 ) echo str_repeat( \" \", $offset ); /* end the table */ echo \'\'; ?>