八达网
标题:
前两天在8达看到有人说学好PHP可以当高帅富,钓丝学了两天,编了个日历。但是点上月下
[打印本页]
作者:
zerg王
时间:
2012-9-23 20:11
标题:
前两天在8达看到有人说学好PHP可以当高帅富,钓丝学了两天,编了个日历。但是点上月下
前两天在8达看到有人说学好PHP可以当高帅富,钓丝学了两天,编了个日历。但是点上月下月不会变化啊,特来跪求木天使指导一下。
//calendar.inc文件
<?php
function create_calendar($tm)
{
$year = date('Y', $tm);
$month = date('n', $tm);
$day = date('d', $tm);
$week = date('w', mktime(0, 0, 0, $month, 1, $year));
$days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$day_num = "";
$count = 0;
$head = array("日", "一", "二", "三", "四", "五", "六");
echo "<table class='calendar'>";
echo "<thead>";
echo "<tr>";
echo "<th class='head'><a href='#'><</a></th>";
echo "<th colspan='5' class='head'>".date('Y年m月', $tm)."</th>";
echo "<th class='head'><a href='#'>></a></th>";
echo "</tr>";
echo "<tr>";
foreach($head as $h)
{
echo "<th>$h</th>";
}
echo "</tr>";
echo "</thead>";
echo "<tbody>";
for($i = 0; $i < 6; $i++)
{
echo "<tr>";
for($j = 0; $j < 7; $j++)
{
if(($j >= $week || $i > 0) && $count < $days)
{
$day_num = ++$count;
if($count == $day)
echo "<td class='celltoday'>".$day_num."</td>";
else
echo "<td class='cellday'>".$day_num."</td>";
}
else
{
$day_num = "";
echo "<td class='cell'>".$day_num."</td>";
}
}
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
}
?>
//html文件
<!DOCTYPE HTML>
<?php
include("calendar.inc");
?>
<html>
<head>
<title>My Calendar Test</title>
<link rel="stylesheet" type="text/css" href="calendar.css" />
</head>
<body>
<?php
for($i = 1; $i <= 12; $i++)
{
echo "<div style='float: left; margin: 10px 10px;'>";
create_calendar(mktime(0,0,0,$i,21,2012));
echo "</div>";
if($i % 4 == 0)
echo "<div style='clear: both;'>";
}
?>
</body>
</html>
//CSS文件
table.calendar {
font-family: arial;
font-size: 12px;
font-weight: normal;
/*border: 1px solid gray;*/
border-spacing: 1px 1px;
background: aliceblue;
}
th.head {
background-color: greenyellow;
text-align: center;
}
td.cellday {
width: 19px;
height: 15px;
background-color: #bbccdd;
text-align: center;
text-decoration: underline;
/*border: 1px solid gray;*/
color: white;
cursor: pointer;
}
td.celltoday {
width: 19px;
height: 15px;
background-color: orange;
text-align: center;
text-decoration: underline;
/*border: 1px solid gray;*/
color: white;
cursor: pointer;
}
td.cell {
width: 19px;
height: 15px;
background-color: #bbccdd;
text-align: center;
text-decoration: underline;
/*border: 1px solid gray;*/
}
复制代码
作者:
三万英尺
时间:
2012-9-23 20:15
天下码农皆屌丝~~~
作者:
The.WK
时间:
2012-9-23 23:29
提示:
作者被禁止或删除 内容自动屏蔽
作者:
小鲵
时间:
2012-9-24 08:15
我也想当高富帅。。。。
作者:
肚顶方向盘
时间:
2012-9-24 08:18
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 八达网 (https://www.8-da.com/)
Powered by Discuz! X2.5