<? 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 [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 "<BR> ";
Echo "<a href = $ HTTP_SERVER_VARS [PHP_SELF]> Back </a> ";
Exit ();
}
?>
<Table width = "200" border = "1" cellspacing = "0" cellpadding = "0" bordercolor = "# E7E7E7" style = "font-size: 12px; "align =" center ">
<Tr align = "center"> <td colspan = "2">
<? Php
// <------- 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 "<a href = $ HTTP_SERVER_VARS [PHP_SELF]? Year = ". ($ year-1)." & month = ". $ month."> </a> year <a href = $ HTTP_SERVER_VARS [PHP_SELF]? Year = ". ($ year + 1)." & month = ". $ month." >></a> ";
?>
</Td> <td colspan = "3"> <? Php echo $ year. "year". $ month. "month";?>
</Td> <td colspan = "2">
<? Php
Echo "<a href = $ HTTP_SERVER_VARS [PHP_SELF]? Month = ". ($ month-1)." & year = ". $ year."> </a> month <a href = $ HTTP_SERVER_VARS [PHP_SELF]? Month = ". ($ month + 1)." & year = ". $ year." >></a> ";
// <-------- Connection processing and output for the previous year, next year, last month, and next month; end --------->
?> </Td> </tr>
<Tr align = center> <td> <font color = "red"> day </font> </td> <td> 1 </td> <td> 2 </ td> <td> 3 </td> <td> 4 </td> <td> 5 </td> <td> 6 </td> </tr> <tr>
<? Php
$ 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 = "<strong> ";
}
Else
{
$ FontStyle = "";
}
Return $ FontStyle;
}
For ($ I = 0; $ I <= $ FirstDay; $ I ++) // This for outputs location 1 of a month
{
For ($ I; $ I <$ FirstDay; $ I ++)
{
Echo "<td align = center> </td> \ n ";
}
If ($ I = $ FirstDay)
{
Echo "<td align = center ". bgcolor ($ month, $ bgtoday, 1, $ year ). "> <font color = ". font_color ($ month, 1, $ year ). "> ". font_style ($ month, 1, $ year ). "1 </font> </td> \ n ";
If ($ FirstDay = 6) // determines whether the first day is Saturday.
{
Echo "</tr> ";
}
}
}
$ 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 "<td align = center ". bgcolor ($ month, $ bgtoday, $ I, $ year ). "> <font color = ". font_color ($ month, $ I, $ year ). "> ". font_style ($ month, $ I, $ year ). "$ I </font> </td> \ n ";
If (date ("w", mktime (0, 0, 0, $ month, $ I, $ year) = 6) // determines whether the day is Saturday.
{
Echo "</tr> \ n ";
}
}
?>
</Table>