ホームページ >php教程 >php手册 >PHPカレンダーコード共通関数

PHPカレンダーコード共通関数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBオリジナル
2016-06-21 08:57:261113ブラウズ
<?php<br/>//calendar.php<br/>//Check if the month and year values exist<br/>if ((!&#36;_GET['month']) && (!&#36;_GET['year'])) &#123;<br/> &#36;month = date ("n");<br/> &#36;year = date ("Y");<br/>&#125; else &#123;<br/> &#36;month = &#36;_GET['month'];<br/> &#36;year = &#36;_GET['year'];<br/>&#125;<br/>//Calculate the viewed month<br/>&#36;timestamp = mktime (0, 0, 0, &#36;month, 1, &#36;year);<br/>&#36;monthname = date("F", &#36;timestamp);<br/>//Now let's create the table with the proper month<br/>?><br><table style="width: 105px; border-collapse: collapse;" border="1" cellpadding="3" cellspacing="0" bordercolor="#000000"><br>   <tr><br>   <td colspan="7" class="calendartodayoff" ><br>    <span style="font-weight: bold;"><?php echo &#36;monthname . " " . &#36;year; ?></span><br>   </td><br>   </tr><br>   <tr><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">Su</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">M</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">Tu</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">W</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">Th</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">F</span><br>   </td><br>   <td class="calendartodayoff" ><br>    <span style="font-weight: bold;">Sa</span><br>   </td><br>   </tr><br>   <?php <br/> &#36;monthstart = date("w", &#36;timestamp);<br/> &#36;lastday = date("d", mktime (0, 0, 0, &#36;month + 1, 0, &#36;year));<br/> &#36;startdate = -&#36;monthstart;<br/> <br/> //Figure out how many rows we need.<br/> &#36;numrows = ceil (((date("t",mktime (0, 0, 0, &#36;month + 1, 0, &#36;year)) + &#36;monthstart) / 7));<br/> <br/> //Let's make an appropriate number of rows...<br/> for (&#36;k = 1; &#36;k <= &#36;numrows; &#36;k++)&#123;<br/> ?><tr><?php<br/> //Use 7 columns (for 7 days)...<br/> for (&#36;i = 0; &#36;i < 7; &#36;i++)&#123;<br/> &#36;startdate++;<br/> if ((&#36;startdate <= 0) || (&#36;startdate > $lastday)){<br>       //If we have a blank day in the calendar.<br>       ?><td style="background: #FFFFFF;"> </td><?php<br/> &#125; else &#123;<br/> <br/> if (&#36;startdate == date("j") && &#36;month == date("n") && &#36;year == date("Y"))&#123;<br/> ?><td class="calendartodayoff" -" . &#36;month . "-" . &#36;startdate; ?>',event);" ><?php echo date ("j"); ?></td><?php<br/> &#125; else &#123;<br/> ?><td class="calendaroff" -" . &#36;month . "-" . &#36;startdate; ?>',event);" ><?php echo &#36;startdate; ?></td><?php<br/> &#125;<br/> &#125;<br/> &#125;<br/> ?></tr><?php<br/> &#125;<br/> ?>    <br></table>



声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。