PHP automatically generates the calendar code .? Php * FunctionWrittenbyNelsonNeoh@32004.Forthosewhowantstoutilizethiscode, pleasedonotremovethisremark. Ifyouhavedoneanyenhancementtothiscode, pleasep /*
Function Written by Nelson Neoh @ 3/2004.
For those who wants to utilize this code, please do not remove this remark.
If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board. Thank you.
Function usage: calendar (Month, Year)
*/
Function calendar ($ MM, $ YYYY ){
If ($ MM = "") $ MM = date ("m ");
If ($ YYYY = "") $ YYYY = date ("Y ");
If (checkdate ($ MM, 1, $ YYYY )){
$ StringDate = strftime ("% d % B % Y", mktime (0, 0, $ MM, 1, $ YYYY ));
$ Days = strftime ("% d", mktime (, 0, $ MM +, $ YYYY ));
$ FirstDay = strftime ("% w", mktime (0, 0, 0, $ MM, 1, $ YYYY ));
$ LastDay = strftime ("% w", mktime (0, 0, 0, $ MM, $ days, $ YYYY ));
$ PrintDays = $ days;
$ PreMonth = strftime ("% m", mktime (, 0, $ MM-1, 1, $ YYYY ));
$ PreYear = strftime ("% Y", mktime (, 0, $ MM-1, 1, $ YYYY ));
$ NextMonth = strftime ("% m", mktime (, 0, 0, $ MM +, $ YYYY ));
$ NextYear = strftime ("% Y", mktime (, 0, 0, $ MM +, $ YYYY ));
Print ("
");Print ("
| P | ");Print ("
". Strftime (" % B % Y ", mktime (0, 0, 0, $ MM, 1, $ YYYY ))." | ");Print ("
N |
");Print ("
");Print ("
| Sun |
Mon |
Tue |
Wed |
Thu |
Fri |
Sat |
");$ CurrentDays = 1;For ($ a = 1; $ a <= 5; $ a ++ ){Print ("
");$ DiffDays = $ firstDay-$ lastDay;If ($ firstDay> $ lastDay & $ currentDays = 1 & ($ diffDays <> 1 )){For ($ x = $ lastDay; $ x> = 0; $ x --){$ PrintDays = $ days-$ x;Print ("
| $ PrintDays | ");}For ($ z = 1; $ z <$ firstDay-$ lastDay; $ z ++ ){Print ("
| ");}For ($ y = $ firstDay; $ y <7; $ y ++ ){Print ("
$ CurrentDays | ");$ CurrentDays ++;}} Elseif ($ firstDay! = 0 & $ currentDays = 1 ){For ($ z = 1; $ z <= $ firstDay; $ z ++ ){Print ("
| ");}For ($ y = $ firstDay; $ y <7; $ y ++ ){Print ("
$ CurrentDays | ");$ CurrentDays ++;}} Else {For ($ u = 1; $ u <= 7 & $ currentDays <= $ days; $ u ++ ){Print ("
$ CurrentDays | ");$ CurrentDays ++;}}Print ("
");}Print ("
");
}
}
?>
Http://www.bkjia.com/PHPjc/314607.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/314607.htmlTechArticle? Php/* Function Written by Nelson Neoh @ 3/2004. for those who wants to utilize this code, please do not remove this remark. if you have done any enhancement to this code, please p...