A php calendar project_php tutorial

Source: Internet
Author: User
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 ";
}
}
?>
$ 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 ="

// <------- 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.
". 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.