<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>
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答