Commit b38a3662 authored by 君塚 悠's avatar 君塚 悠

プログラム作成(calendar.php:カレンダー生成)

parent ee0566dd
<?php
if ($_GET['num']=='') {
$today_year =date("Y");
$today_month=date("n");
} else {
$timestamp=mktime(0, 0, 0, date("n") + $_GET['num'],
date("d"), date("Y"));
$today_year = date("Y", $timestamp);
$today_month =date("n", $timestamp);
}
$current = mktime(0, 0, 0, $today_month, 1, $today_year);
$first_day =date("w",$current);
$last_day = date("t",$current);
?>
<html>
<body>
<h1 style = "background:#cccccc">
<?php print(date("Y年m月", $current)); ?>
のカレンダ</h1>
<table border="1" width="300">
<tr>
<th>日</th><th>月</th><th>火</th><th>水</th>
<th>木</th><th>金</th><th>土</th>
</tr>
<?php
for ($i = 1; $i <= first_day + $last_day; $i++) {
if ($i % 7 == 1) {print ("<tr>");}
if($i > $first_day) {
print("<td>".($i-first)."</td>");
} else {
print("<td> & nbsp;</td>");
}
if ($i % 7 == 0) {print("</tr>"); }
}
?>
</table>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment