亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Calendar page display

1, Use the mktime() function to get the number of days in the current month and the week on the 1st of the month (2018/3/13)

<?php
$day=date("t",mktime(0,0,0,$mon,1,$year));//當前月的天數(shù)  31
$w=date("w",mktime(0,0,0,$mon,1,$year));//當月1號的星期幾  4

2, Output the header information of the calendar

<?php
echo"<div align='center'>";
echo"<table border='0'>";
echo"<h3><div>{$year}年{$mon}月</div></h3>";
echo "<tr>";
echo "<th>日</th>";
echo "<th class='td1'>一</th>";
echo "<th class='td1'>二</th>";
echo "<th class='td1'>三</th>";
echo "<th class='td1'>四</th>";
echo "<th class='td1'>五</th>";
echo "<th>六</th>";
echo "</tr>";

3, Traverse the output calendar

Analysis:

From the mktime() function, we can know the total number of days in the current month. The day of the week is the 1st of the month. It only needs to be less than the total number of days in the current month. Each time, 7-day traversal output is performed.

Start from the day of the week corresponding to the 1st of the month and add 1 every day. The 7-day cycle is one row of data, so the calendar comes out

Code:

<?php
$d=1;
while($d<=$day){
    echo"<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'>";
    for($i=1;$i<=7;$i++){//循環(huán)輸出7天信息
        if($d<=$day&&($w<$i||$d!=1)){
            echo "<th><a href=''>{$d}</a></th>";
            $d++;
        }else{
            echo"<th> </th>";
        }
    }
}

The running results are as follows:

微信圖片_20180313153005.png

Continuing Learning
||
<?php echo "日歷的基本顯示";
submitReset Code