simpele-kalender
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
// datepicker1.php
define("ADAY", (60*60*24));
$me = basename($_SERVER['PHP_SELF']);
$posted = isset($_REQUEST['submit']);
if (!$posted || !checkdate($_POST['maand'], 1, $_POST['jaar'])) {
$nowArray = getdate();
$maand = $nowArray['mon'];
$jaar = $nowArray['year'];
} else {
$maand = $_POST['maand'];
$jaar = $_POST['jaar'];
}
$start = mktime (12, 0, 0, $maand, 1, $jaar);
$firstDayArray = getdate($start);
$maanden = Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli",
"Augustus", "Sebtember", "Oktober", "November", "December");
$maandselect = "
<select name=\"maand\">
";
for ($x=1; $x <= count($maanden); $x++) {
$maandselect .= "<option value=\"$x\"";
if ($x == $maand) {
$maandselect .= " SELECTED";
}
$maandselect .= ">".$maanden[$x-1]."";
}
$maandselect .= "
</select>
";
$jaarselect = "
<form method=\"post\" action=\"$me\">
<select name=\"jaar\">
";
for ($x=1980; $x<=2010; $x++) {
$jaarselect .= "<option";
if ($x == $jaar) {
$jaarselect .= " SELECTED";
}
$jaarselect .= ">$x";
}
$jaarselect .= "
</select>
";
$dagen = Array("Zon","Maa","Din","Woe","Don","Vri","Zat");
$maandkalender = "
<TABLE BORDER=1 CELLPADDING=5><tr>
";
foreach ($dagen as $dag) {
$maandkalender .= "<TD BGCOLOR=\"#cccccc\" ALIGN=CENTER><strong>$dag</strong></td>\n";
}
for ($count=0; $count < (6*7); $count++) {
$dagArray = getdate($start);
if (($count % 7) == 0) {
if ($dagArray['mon'] != $maand) {
break;
} else {
$maandkalender .= "</tr><tr>\n";
}
}
if ($count < $firstDayArray['wday'] ||
$dagArray['mon'] != $maand) {
$maandkalender .= "<td> </td>\n";
} else {
$maandkalender .= "<td>".$dagArray['mday']." </td>\n";
$start += ADAY;
}
}
$maandkalender .= "</tr></table>";
?>
<html>
<head>
<title><?php echo "Kalender:".$firstDayArray['month']."".$firstDayArray['year'] ?></title>
</head>
<body>
<form method="post" action="<?=$me ?>">
<?php echo $maandselect; ?>
<?php echo $jaarselect; ?>
<input type="submit" name="submit" value="Go!">
</form>
<?php echo $maandkalender; ?>
</body>
</html>
// datepicker1.php
define("ADAY", (60*60*24));
$me = basename($_SERVER['PHP_SELF']);
$posted = isset($_REQUEST['submit']);
if (!$posted || !checkdate($_POST['maand'], 1, $_POST['jaar'])) {
$nowArray = getdate();
$maand = $nowArray['mon'];
$jaar = $nowArray['year'];
} else {
$maand = $_POST['maand'];
$jaar = $_POST['jaar'];
}
$start = mktime (12, 0, 0, $maand, 1, $jaar);
$firstDayArray = getdate($start);
$maanden = Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli",
"Augustus", "Sebtember", "Oktober", "November", "December");
$maandselect = "
<select name=\"maand\">
";
for ($x=1; $x <= count($maanden); $x++) {
$maandselect .= "<option value=\"$x\"";
if ($x == $maand) {
$maandselect .= " SELECTED";
}
$maandselect .= ">".$maanden[$x-1]."";
}
$maandselect .= "
</select>
";
$jaarselect = "
<form method=\"post\" action=\"$me\">
<select name=\"jaar\">
";
for ($x=1980; $x<=2010; $x++) {
$jaarselect .= "<option";
if ($x == $jaar) {
$jaarselect .= " SELECTED";
}
$jaarselect .= ">$x";
}
$jaarselect .= "
</select>
";
$dagen = Array("Zon","Maa","Din","Woe","Don","Vri","Zat");
$maandkalender = "
<TABLE BORDER=1 CELLPADDING=5><tr>
";
foreach ($dagen as $dag) {
$maandkalender .= "<TD BGCOLOR=\"#cccccc\" ALIGN=CENTER><strong>$dag</strong></td>\n";
}
for ($count=0; $count < (6*7); $count++) {
$dagArray = getdate($start);
if (($count % 7) == 0) {
if ($dagArray['mon'] != $maand) {
break;
} else {
$maandkalender .= "</tr><tr>\n";
}
}
if ($count < $firstDayArray['wday'] ||
$dagArray['mon'] != $maand) {
$maandkalender .= "<td> </td>\n";
} else {
$maandkalender .= "<td>".$dagArray['mday']." </td>\n";
$start += ADAY;
}
}
$maandkalender .= "</tr></table>";
?>
<html>
<head>
<title><?php echo "Kalender:".$firstDayArray['month']."".$firstDayArray['year'] ?></title>
</head>
<body>
<form method="post" action="<?=$me ?>">
<?php echo $maandselect; ?>
<?php echo $jaarselect; ?>
<input type="submit" name="submit" value="Go!">
</form>
<?php echo $maandkalender; ?>
</body>
</html>