A php calendar program .? Php ------- process the variables submitted through the GET method; start -------- if ($ HTTP_GET_VARS [year]) {$ HTTP_GET_VARS [year] date (Y);} if ($ HTTP_GET_VARS [month]) {$ HTTP_GET_VARS [mon // <------- Process the variables submitted through the GET method; start -------->
If ($ HTTP_GET_VARS [year] = "")
{
$ HTTP_GET_VARS [year] = date ("Y ");
}
If ($ HTTP_GET_VARS [month] = "")
{
$ HTTP_GET_VARS [month] = date ("n ");
}
$ Month = $ HTTP_GET_VARS [month];
$ Year = $ HTTP_GET_VARS [year];
// <------- Process the variables submitted through the GET method; end -------->
If ($ year <1971)
{
Echo "error! ";
Echo"
";
Echo "Back ";
Exit ();
}
?>
";
}
Else
{
$ FontStyle = "";
}
Return $ FontStyle;
}
For ($ I = 0; $ I <= $ FirstDay; $ I ++) // this for outputs location 1 of a month
{
For ($ I; $ I <$ FirstDay; $ I ++)
{
Echo" \ N ";
}
If ($ I = $ FirstDay)
{
Echo" \ N ";
If ($ FirstDay = 6) // determines whether the first day is Saturday.
{
Echo" ";
}
}
}
$ CountMonth = date ("t", mktime (0, 0, 0, $ month, 1, $ year); // The total number of days of a month
For ($ I = 2; $ I <= $ countMonth; $ I ++) // The number of all numbers from the second to the end of the month.
{
Echo" \ N ";
If (date ("w", mktime (0, 0, 0, $ month, $ I, $ year) = 6) // determines whether the day is Saturday.
{
Echo" \ N ";
}
}
?>
// <------- Processing when the month exceeds 1 to 12; start ------->
If ($ month <1)
{
$ Month = 12;
$ Year-= 1;
}
If ($ month> 12)
{
$ Month = 1;
$ Year + = 1;
}
// <------- Processing when the month exceeds 1 to 12; end ------->
//************************************** *
// <--------- Connection processing and output for the previous year, next year, last month, and next month; start --------->
Echo "< <年> > ";
?>
|
|
Echo "< <月> > ";
// <-------- Connection processing and output for the previous year, next year, last month, and next month; end --------->
?> |
| Day |
I |
II |
3. |
Thu |
V. |
Sat. |
$ D = date ("d ");$ FirstDay = date ("w", mktime (0, 0, 0, $ month, 1, $ year); // Obtain the day of the week for the first day of any month, the number 1 is calculated starting from the number of cells in the table.$ Bgtoday = date ("d ");Function font_color ($ month, $ today, $ year) // calculate the font color of Sunday.{$ Sunday = date ("w", mktime (0, 0, 0, $ month, $ today, $ year ));If ($ Sunday = "0 "){$ FontColor = "red ";}Else{$ FontColor = "black ";}Return $ FontColor;}Function bgcolor ($ month, $ bgtoday, $ today_ I, $ year) // calculates the background color of the current day.{$ Show_today = date ("d", mktime (0, 0, 0, $ month, $ today_ I, $ year ));$ Sys_today = date ("d", mktime (0, 0, 0, $ month, $ bgtoday, $ year ));If ($ show_today = $ sys_today){$ Bgcolor = "bgcolor = # 6699FF ";}Else{$ Bgcolor = "";}Return $ bgcolor;}Function font_style ($ month, $ today, $ year) // calculate the font style of Sunday.{$ Sunday = date ("w", mktime (0, 0, 0, $ month, $ today, $ year ));If ($ Sunday = "0 "){$ FontStyle ="
|
". Font_style ($ month, 1, $ year)." 1 |
| ". Font_style ($ month, $ I, $ year)." $ I |
Http://www.bkjia.com/PHPjc/317347.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/317347.htmlTechArticle? Php // ------- process the variables submitted through the GET method; start -------- if ($ HTTP_GET_VARS [year] = "") {$ HTTP_GET_VARS [year] = date ("Y");} if ($ HTTP_GET_VARS [month] = "") {$ HTTP_GET_VARS [mon...