This article mainly introduces the calendar program implemented by php, which can implement basic calendar display and real-time query functions, which is of great practical value, for more information about the calendar program implemented by php, see the next article. It provides basic calendar display and real-time query functions.
This example describes the calendar program implemented by php. Share it with you for your reference. The details are as follows:
"; $ Col = 0; // Print the table header ///?>
"; $ U2 ="
The running effect is as follows:
1900) echo $ Year-1; else echo $ Year;?> & Amp; Month = "OnClick =" javascript: document. linked. submit (); "name =" Year "> < & Amp; Month = "OnClick =" javascript: document. linked. submit (); "name =" Year ">>> |
|
& Amp; Month = 0) if ($ Month-1 <10) echo "0". ($ Month-1); else echo $ Month-1; else echo $ Month;?> "OnClick =" javascript: document. linked. submit (); "name =" Month "> < & Amp; Month = "OnClick =" javascript: document. linked. submit (); "name =" Month ">>> |
|
". $ Weekvalue .""; Echo"
"; //// Print the date list ///// when the month is, a value is deleted from the end of the array, that is, 31 is deleted. if ($ Month = 4 or $ Month = 6 or $ Month = 9 or $ Month = 11) {array_pop ($ Maxday); $ Maxday_count --;} // first judge whether the month is February. If yes, then judge whether the year is a leap year. if yes, remove two values from the end of the array; otherwise, remove three values. if ($ Month = 2) {if ($ Year % 4 = 0) {array_pop ($ Maxday); $ Maxday_count-= 2 ;} else {array_pop ($ Maxday); $ Maxday_count-= 3 ;}} //// print the date //// while ($ daynum <$ Maxday_count) {echo"
"; While (list ($ colnum, $ Dayvalue) = each ($ Maxday) {// determines the day of the week when the current date is set to $ DayWeek = date (" w ", strtotime ($ Year. "-". $ Month. "-". $ Dayvalue); // when the current date is at 1st, that is, the first day of each month, add the corresponding blank grid if ($ Dayvalue = 1) in front of it) for ($ I = 0; $ I <$ DayWeek; $ I ++) echo $ space; // print several blank grids each month $ daynum ++; // compare the printed date with the current date string. if the date is equal, the font is marked in red. if ($ Year. $ Month. $ Dayvalue = $ Today) {$ u1 ="";}Else {$ u1 =" "; $ u2 =" ";}if ($ DayWeek = 0 or $ DayWeek = 6) $ color =" red "; else $ color = "black"; echo"
". $ U1. $ Dayvalue. $ u2 ." | "; // Add 1 to the value of the day of the week. if it is a multiple of 7, wrap the line to exit this loop (line feed printing) if ($ DayWeek + 1) % 7 = 0) {$ col ++; break ;}} echo"
";}?>