PHP simple calendar

Source: Internet
Author: User

1.

<Head> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/> <br/> <MCE: style> <! -- <Br/> caption {margin-bottom: 6px ;}< br/> table {background-color: #9ec5e0; margin-left: 80px ;} <br/> Th {background-color: # edf2f5; font-size: 14px ;}< br/> TD {text-align: center; Vertical-align: middle; background-color: White; font-size: 14px ;}< br/> --> </MCE: style> <style mce_bogus = "1"> caption {margin-bottom: 6px ;}< br/> table {background-color: #9ec5e0; margin-left: 80px ;}< br/> Th {background-color: # edf2f5; font-Si Ze: 14px ;}< br/> TD {text-align: center; Vertical-align: middle; Background-color: White; font-size: 14px ;} </style> <br/> </pead> <br/> <body> <br/> <? Php <br/> $ Yue = $ _ post ["Yue"]; <br/> $ Nian = $ _ post ["Nian"]; <br/>?> <Br/> <form method = "Post" Action = "calender_only.php"> <br/> enter the following year: <input type = "text" name = "Nian" value = "<? PHP if ($ _ post ["Nian"] = "") {echo "2009";} else {echo $ _ post ["Nian"] ;}?> "/> <Br/> Please enter the month: <input type =" text "name =" Yue "value =" <? PHP if ($ _ post ["Yue"] = "") {echo "11";} else {echo $ _ post ["Yue"] ;}?> "/> <Br/> <input type =" Submit "value =" Submit "> <br/> </form> <br/> <? PHP if ($ Yue = "" | $ Nian = "") {<br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/> if ($ Nian> 2039 | $ Nian <1970 | $ Yue <1 | $ Yue> 12) {<br/> echo "<MCE: Script Type = 'text/JavaScript '> <! -- <Br/> alert ('the input data is invalid !! ') <Br/> // --> </MCE: SCRIPT> "; <br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/>?> <Br/> <Table> <br/> <caption> <B> <? PHP echo $ Nian. "year". $ Yue. "month"?> </B> </caption> <br/> <tr> <br/> <TH> day </Th> <br/> <TH> 1 </Th> <br/> <TH> 2 </Th> <br/> <TH> 3 </Th> <br/> <TH> 4 </Th> <br/> <th> 5 </Th> <br/> <TH> 6 </Th> <br/> </tr> <br/> <? Php <br/> // obtain the number of days <br/> $ num_days = date ("T", mktime (, 0, $ Yue, 1, $ Nian )); <br/> $ BR = 0; <br/> // obtain the day of the week on the first day. <br/> $ first_day = date ("N", mktime (, 0, 0, $ Yue, 1, $ Nian); <br/> // first, determine the location of the first day, and then use other loops <br/> if ($ first_day! = 7) {<br/> echo "<TD colspan = '". $ first_day. "'> </TD>" ;}< br/> // if the first day is not the day of the week, several cells need to be empty. <br/> for ($ I = 1; $ I <= $ num_days; $ I ++) {<br/> echo "<TD> ". $ I. "</TD>"; <br/> // line feed <br/> If ($ I + $ first_day) % 7 = 0) {echo "</tr> <tr>" ;}< br/>}?> <Br/> </tr> <br/> </table> <br/> </body> 

 

 

2.

<Head> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/> <br/> <MCE: style> <! -- <Br/> ul {list-style-type: None ;}< br/> span {width: 24px; <br/> Height: 24px; <br/> text-align: center; <br/> font-weight: bold; <br/> float: Left; <br/> margin-left: 20px; <br/> padding-top: 13px; <br/>}< br/> Li {clear: both} <br/> --> </MCE: style> <style mce_bogus = "1"> ul {list-style-type: None ;}< br/> span {width: 24px; <br/> Height: 24px; <br/> text-align: center; <br/> font-weight: bold; <br/> float: Left; <br/> margin-le FT: 20px; <br/> padding-top: 13px; <br/>}< br/> Li {clear: both} </style> <br/> </pead> <br/> <body> <br/> <? Php <br/> $ Yue = $ _ post ["Yue"]; <br/> $ Nian = $ _ post ["Nian"]; <br/>?> <Br/> <form method = "Post" Action = "ulli. PHP "> <br/> enter the year: <input type =" text "name =" Nian "value =" <? PHP if ($ _ post ["Nian"] = "") {echo "2009";} else {echo $ _ post ["Nian"] ;}?> "/> <Br/> Please enter the month: <input type =" text "name =" Yue "value =" <? PHP if ($ _ post ["Yue"] = "") {echo "11";} else {echo $ _ post ["Yue"] ;}?> "/> <Br/> <input type =" Submit "value =" Submit "> <br/> </form> <br/> <? PHP if ($ Yue = "" | $ Nian = "") {<br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/> if ($ Nian> 2039 | $ Nian <1970 | $ Yue <1 | $ Yue> 12) {<br/> echo "<MCE: Script Type = 'text/JavaScript '> <! -- <Br/> alert ('the input data is invalid !! ') <Br/> // --> </MCE: SCRIPT> "; <br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/>?> <Br/> <ul> <br/> <li> <span> day </span> <span> 1 </span> <span> 2 </span> <Span> 3 </span> <span> 4 </span> <span> 5 </span> <span> 6 </span> </LI> <br/> <li> <br/> <? Php <br/> // obtain the number of days <br/> $ num_days = date ("T", mktime (, 0, $ Yue, 1, $ Nian )); <br/> // obtain the day of the week on the first day <br/> $ first_day = date ("N", mktime (, 0, $ Yue, 1, $ Nian )); <br/> // first determine the location of the first day, and then use other loops <br/> if ($ first_day! = 7) {<br/> for ($ I = 0; $ I <$ first_day; $ I ++) {<br/> echo "<span> </span> "; <br/>}< br/> // if the first day is not the day of the week, several cells need to be empty. <br/> for ($ I = 1; $ I <= $ num_days; $ I ++) {<br/> echo "<span> ". $ I. "</span>"; <br/> // line feed <br/> If ($ I + $ first_day) % 7 = 0) {echo "</LI> <li>" ;}< br/>}?> <Br/> </LI> <br/> </ul> <br/> </body> 

 

 

3.

<MCE: style> <! -- <Br/> ul {list-style-type: none; clear: Both; overflow: hidden; width: 302px; Border: 1px red solid; Background-color: # f0f0f0; padding-left: 20px ;}< br/> Li {float: Left; width: 40px; padding: 10px 0 10px 0 ;}< br/> --> </MCE: style> <style mce_bogus = "1"> ul {list-style-type: none; clear: Both; overflow: hidden; width: 302px; Border: 1px red solid; background-color: # f0f0f0; padding-left: 20px ;}< br/> Li {float: Left; width: 40px; paddin G: 10px 0 10px 0 ;}</style> <br/> <? Php <br/> $ Yue = $ _ post ["Yue"]; <br/> $ Nian = $ _ post ["Nian"]; <br/> if ($ Yue = "" | $ Nian = "") {<br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/>?> <Br/> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> function set () {<br/> var Yue = document. getelementbyid ('incang '). value; <br/> var OOP = document. getelementbyid ('month '). options; <br/> for (VAR I = 0; I <oop. length; I ++) {<br/> If (Yue = OOP [I]. value) {<br/> OOP [I]. selected = "selected"; <br/>}< br/> // --> </MCE: SCRIPT> <br/> <body onload = "set ();"> <br/> <? PHP if ($ Nian> 2039 ||$ Nian <1970 ||| Yue <1 ||$ Yue> 12) {<br/> echo "<MCE: script Type = 'text/JavaScript '> <! -- <Br/> alert ('the input data is invalid !! ') <Br/> // --> </MCE: SCRIPT> "; <br/> $ Yue = 11; <br/> $ Nian = 2009; <br/>}< br/>?> <Br/> <form method = "Post" Action = "calend_tc.php"> <br/> enter the following year: <input type = "text" name = "Nian" value = "<? PHP if ($ _ post ["Nian"] = "") {echo "2009";} else {echo $ _ post ["Nian"] ;}?> "/> <Br/> enter the month: <select id = "month" name = "Yue"> <br/> <option value = "1"> August 1, January </option> <br/> <option value = "2 "> April February </option> <br/> <option value =" 3 "> April March </option> <br/> <option value =" 4 "> April </Option> <br/> <option value = "5"> August 1, May </option> <br/> <option value = "6"> August 1, June </option> <br/> <option value = "7"> July </option> <br/> <option value = "8"> August </option> <br/> <option value = "9"> September </option> <br/> <option value = "10"> October </option> <br /> <Option value = "11"> November </option> <br/> <option value = "12"> December </option> <br/> </SELECT> <br/> <input type = "hidden" id = "yincang" value = "<? PHP echo $ Yue;?> "/> <Br/> <input type =" Submit "value =" Submit "> <br/> </form> <br/> <ul> <br/> <LI> day </LI> <li> 1 </LI> <li> 2 </LI> <li> 3 </LI> <li> 4 </LI> <LI> 5 </LI> <li> 6 </LI> <br/> <? Php <br/> $ num_days = date ("T", mktime (0, 0, $ Yue, 1, $ Nian )); <br/> $ first_day = date ("N", mktime (0, 0, $ Yue, 1, $ Nian); <br/> if ($ first_day! = 7) {<br/> for ($ I = 0; $ I <$ first_day; $ I ++) {<br/> echo "<li> </LI>"; <br/>}< br/> for ($ I = 1; $ I <$ num_days; $ I ++) {<br/> echo "<li> ". $ I. "</LI>"; <br/>}< br/>?> <Br/> </ul> <br/> </body> 

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.