PHP outputs the calendar table code instance, and php outputs the calendar instance. PHP outputs the calendar table code instance, and php outputs the calendar instance! DOCTYPEhtmlPUBLIC-W3CDTDXHTML1.0TransitionalENwww.w3.orgTRxhtml1DTDxhtml1-transitional.dtdhtmlx PHP output calendar table code instance, php output calendar instance
Calendar<? Php $ MONTH = array ("lunar January", "January", "February", "March", "April", "May", "June", "July ", "August", "August"); $ enMONTH = array ("August", "January", "February ", "Marcy", "April", "May", "June", "July", "August", "September", "October", "November ", "December"); $ WEEK = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Saturday "); $ BACKCOLOR = array ("# FFC", "# FFF", "#9F6", "# FFC", "#6F0", "#6F6", "# F90 ", "# F06", "# F00", "# FC3", "# FF6", "# F99"); function PrintMon ($ year, $ mon) {date_default_timezone_set ("Asia/Shanghai"); global $ MONTH; global $ enMONTH; global $ WEEK; global $ BACKCOLOR; $ startdate = strtotime ("1 $ enMONTH [$ mon] $ year"); // Obtain the query year and month $ enddate = strtotime ("+ 1 month", $ startdate ); // get the start date of the next month as the end time of the calendar output $ theDate = getdate ($ startdate ); // Convert the date to the string format $ color = $ BACKCOLOR [$ mon]; // set the background color of the calendar echo ("
Success! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" html x...
"); $ Ym = $ year." year ". $ MONTH [$ mon]; echo ("
$ Ym
"); Echo ("
"); For ($ I = 0; $ I <7; $ I ++) // output the day of the week {echo ("
"); Echo (" $ WEEK [$ I] "); echo (" | ");} Echo ("
"); $ TheWeek = $ theDate [wday]; // Determine the day of the week for ($ I = 0; $ I <6; $ I ++) {echo ("
"); For ($ j = 0; $ j <7; $ j ++) {echo ("
"); If ($ startdate <$ enddate & $ theWeek = $ j) // output the date to the column of the corresponding day of the week, do not exceed the current month date {$ theDay = $ theDate [mday]; echo ("$ theDay"); $ startdate = strtotime ("+ 1 day", $ startdate ); // one day before the date is moved forward $ theDate = getdate ($ startdate); // update date $ theWeek = ($ theWeek + 1) % 7; // update week} echo (" | ");} Echo ("
"); If ($ startdate = $ enddate) // if all dates have been output, end loop {$ I = 6 ;}} echo ("<? Php $ year = $ _ POST ['myyear']; $ month = $ _ POST ['mymonth']; if (is_numeric ($ year) & $ year> = 1970 & $ year <2038) {if (is_numeric ($ month) & $ month> = 1 & $ month <= 12) {PrintMon ($ year, $ month);} else if ($ month! = NULL) {echo ("The month is incorrect "."") ;}} Else if ($ year! = NULL) {echo ("The year is incorrect "."") ;}?>