While lus niet herhalen.
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?
$dbhost = "*";
$dbuser = "*";
$dbpass = "*";
$dbdbdb = "*";
if (!@mysql_select_db($dbdbdb, @mysql_connect($dbhost, $dbuser, $dbpass)))
{
echo("Geen verbinding met de database!");
exit();
}
$i=0;
$month=$_GET['month'];
$year=$_GET['year'];
if ((!$year) || ($year < 1970) || ($year > 2036) || (!is_numeric($year)))
{
$year = date("Y");
}
if ((!$month) || ($month < 1) || ($month > 12) || (!is_numeric($month)))
{
$month = date("m");
}
set_time_limit(1);
$this_day = mktime(0,0,0,date("m"),date("d"),date("Y"));
$month_end = date("t",mktime(0,0,0,$month+1,0,$year));
$month_start_day = date("w",mktime(0,0,0,$month,1,$year));
if ($month_start_day == 0)
{
$month_start_day = 7;
}
$tedoen =0;
$months = Array("01","02","03","04","05","06","07","08","09","10","11","12");
$days = Array("M","T","W","T","F","S","S");
echo ("<table border=0 cellspacing=0 cellpadding=0 width=140>\n");
for ($i=0;$i<7;$i++)
{
echo ("<td align=center><b>".$days[$i]."</b></td>\n");
}
echo ("</tr>
<tr>\n");
$days_open=0;
for ($i=1;$i<$month_start_day;$i++) {
echo ("<td> </td>\n");
$days_open++; }
$row = 1;
for ($i=1;$i<=$month_end;$i++)
{
$day = date("w",mktime(0,0,0,$month,$i,$year));
$datenow = mktime(0,0,0,$month,$i,$year);
$mond = date("m",mktime(0,0,0,$month,1,$year));
$result = mysql_query("SELECT * FROM kalender");
if ($i <10)
{
$pre_day = "0";
}
else
{
$pre_day = "";
}
if ($datenow == $this_day)
{
while (list($id, $date, $comment) = mysql_fetch_row($result))
{
if ("".$i."-".$month."-".$year."" == $date)
{
echo("<td align=center><b><a href=''>".$pre_day.$i."</a></b></td>\n");
}
else
{
echo ("<td align=center><b>".$pre_day.$i."</b></td>\n");
}
}
}
else
{
while (list($id, $date, $comment) = mysql_fetch_row($result))
{
if ("".$i."-".$month."-".$year."" == "$date")
{
echo("<td align=center><a href=>".$pre_day.$i."</a></td>\n");}
else
{
echo ("<td align=center>".$pre_day.$i."</td>\n");
}
}
}
if (($day == 0) && ($i != $month_end))
{
echo ("</tr>
<tr>\n"); $row++;
}
}
$days_over= (($row*7)-$month_end)-$days_open;
for ($i=1;$i<=$days_over;$i++)
{
echo ("<td> </td>\n");
}
echo ("</tr>\n");
if ($month==1)
{
$prev_month = 12;
$prev_year = $year-1;
}
else
{
$prev_month = $month-1;
$prev_year = $year;
}
if ($month==12)
{
$next_month= 1;
$next_year= $year+1;
}
else
{
$next_month= $month+1;
$next_year= $year;
}
echo ("</table>
<a href=$PHP_SELF?month=$prev_month&year=$prev_year>Vorige</a> [ ".$months[$month-1]." - $year ] <a href=$PHP_SELF?month=$next_month&year=$next_year>Volgende</a>");
?>
$dbhost = "*";
$dbuser = "*";
$dbpass = "*";
$dbdbdb = "*";
if (!@mysql_select_db($dbdbdb, @mysql_connect($dbhost, $dbuser, $dbpass)))
{
echo("Geen verbinding met de database!");
exit();
}
$i=0;
$month=$_GET['month'];
$year=$_GET['year'];
if ((!$year) || ($year < 1970) || ($year > 2036) || (!is_numeric($year)))
{
$year = date("Y");
}
if ((!$month) || ($month < 1) || ($month > 12) || (!is_numeric($month)))
{
$month = date("m");
}
set_time_limit(1);
$this_day = mktime(0,0,0,date("m"),date("d"),date("Y"));
$month_end = date("t",mktime(0,0,0,$month+1,0,$year));
$month_start_day = date("w",mktime(0,0,0,$month,1,$year));
if ($month_start_day == 0)
{
$month_start_day = 7;
}
$tedoen =0;
$months = Array("01","02","03","04","05","06","07","08","09","10","11","12");
$days = Array("M","T","W","T","F","S","S");
echo ("<table border=0 cellspacing=0 cellpadding=0 width=140>\n");
for ($i=0;$i<7;$i++)
{
echo ("<td align=center><b>".$days[$i]."</b></td>\n");
}
echo ("</tr>
<tr>\n");
$days_open=0;
for ($i=1;$i<$month_start_day;$i++) {
echo ("<td> </td>\n");
$days_open++; }
$row = 1;
for ($i=1;$i<=$month_end;$i++)
{
$day = date("w",mktime(0,0,0,$month,$i,$year));
$datenow = mktime(0,0,0,$month,$i,$year);
$mond = date("m",mktime(0,0,0,$month,1,$year));
$result = mysql_query("SELECT * FROM kalender");
if ($i <10)
{
$pre_day = "0";
}
else
{
$pre_day = "";
}
if ($datenow == $this_day)
{
while (list($id, $date, $comment) = mysql_fetch_row($result))
{
if ("".$i."-".$month."-".$year."" == $date)
{
echo("<td align=center><b><a href=''>".$pre_day.$i."</a></b></td>\n");
}
else
{
echo ("<td align=center><b>".$pre_day.$i."</b></td>\n");
}
}
}
else
{
while (list($id, $date, $comment) = mysql_fetch_row($result))
{
if ("".$i."-".$month."-".$year."" == "$date")
{
echo("<td align=center><a href=>".$pre_day.$i."</a></td>\n");}
else
{
echo ("<td align=center>".$pre_day.$i."</td>\n");
}
}
}
if (($day == 0) && ($i != $month_end))
{
echo ("</tr>
<tr>\n"); $row++;
}
}
$days_over= (($row*7)-$month_end)-$days_open;
for ($i=1;$i<=$days_over;$i++)
{
echo ("<td> </td>\n");
}
echo ("</tr>\n");
if ($month==1)
{
$prev_month = 12;
$prev_year = $year-1;
}
else
{
$prev_month = $month-1;
$prev_year = $year;
}
if ($month==12)
{
$next_month= 1;
$next_year= $year+1;
}
else
{
$next_month= $month+1;
$next_year= $year;
}
echo ("</table>
<a href=$PHP_SELF?month=$prev_month&year=$prev_year>Vorige</a> [ ".$months[$month-1]." - $year ] <a href=$PHP_SELF?month=$next_month&year=$next_year>Volgende</a>");
?>
Dit is een script voor een kalender en het werkt ook. Maar hij laat nu alle datums dubbel zien door de whiule lus. Weet iemand hoe ik dit moet oplossen?
Gewijzigd op 02/02/2004 15:41:00 door Jaap
Er zijn nog geen reacties op dit bericht.