<head><style>th{font-family:隸書;color:#0099ff;}table{background:#99ffcc;}#tr1{background:#00ccff;}.td1{color:#009999;}a{color:#ff9900;}</style></head><body><?php//php日歷//1.date()函數獲取當前的年月$year=$_GET["y"]?$_GET["y"]:date("Y");$mon=$_GET["m"]?$_GET["m"]:date("m");//2.mktime()函數的使用,獲取當前月的天數及當月1號的星期$day=date("t",mktime(0,0,0,$mon,1,$year));$w=date("w",mktime(0,0,0,$mon,1,$year));//3.輸出日歷的頭部信息echo"<center>";echo"<table border='0'>";echo"<h3><font color='#00ff33'font-face='隸書'>{$year}年{$mon}月</font></h3>";echo "<tr id='tr1'onmouseOver='overTr(this)'onmouseOut='outTr(this)'>";echo "<th style='color:#ff0000;'onmouseOver='overTr(this)'onmouseOut='outTr(this)'>日</th>";echo "<th html' target='_blank'>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 style='color:#ff0000;'>六</th>";echo "</tr>";//4.遍歷輸出日歷$d=1;while($d<=$day){ echo"<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'>"; for($i=1;$i<=7;$i++){//循環輸出7天信息 if($d<=$day&&($w<=$i||$d!=1)){ echo "<th>{$d}</th>"; $d++; }else{ echo"<th></th>"; } }}//5.處理上下月,上下年的信息$prey=$nexty=$year;$prem=$nextm=$mon;if($prem<=1){$prem=12;$prey--;}else{$prem--;}if($nextm>=12){$nextm=1;$nexty++;}else{$nextm++;}$prey=$year-1;//上一年$nexty=$year+1;//上一月//超鏈接echo "<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'><td colspan='7'align='center'>";echo"<a href='sy1.php?y={$prey}'><<</a>";echo "<font face='隸書'color='#663399'>{$year}年</font>";echo "<a href='sy1.php?y={$nexty}'>>></a>";echo"";echo"<a href='sy1.php?m={$prem}'><</a>";echo "<font face='隸書'color='#663399'>{$mon}月</font>";echo "<a href='sy1.php?m={$nextm}'>></a>";echo "</td></tr>";echo"</table>";echo"</center>";?><script type='text/JavaScript'>var oriCol=null;function overTr(obj){oriCol=obj.bgColor;obj.bgColor='#00ff99';}function outTr(obj){obj.bgColor=oriCol; }</script></body></html>
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答