Volgende/vorige
Je krijgt alle foto's verkleind te zien in een tabel, en als je erop klikt, opent zich een popup met de foto erin.
Maar nu zou ik graag willen dat er boven die foto een vorige en volgende knop zat om naar de volgende foto te gaan.
Script:
<html>
<head>
<title>Kiët de Kaoje Hook</title>
<center>Klik <a href="uploaden.php" target="hoofd">hier</a> om een plaatje te uploaden.</center><br><br>
Code (php)
<script language="JavaScript">
<!--
function laatZien(fotonr, hoogte, breedte, src)
{
foto = window.open('','','menubar=no,toolbar=no');
foto.resizeTo(breedte,hoogte);
foto.document.write("<html><head><title>Foto - " + fotonr + "</title></head><body leftmargin='0' topmargin='0'>");
foto.document.write("<center><img src=" + src + fotonr + "><center><br>");
foto.document.write("<center><font face='Arial, Helvetica, sans-serif' size='2'>.::<a href='JavaScript:window.close();'> Sluit venster </a>::.</font></center>");
foto.document.write("</body></html>");
}
!-->
</script>
</head>
<body bgcolor="#3a444f" text="dbdbdb">
<STYLE type=text/css>A:link {
COLOR: #ffffff; TEXT-DECORATION: none
}
A:visited {
COLOR: #ffffff; TEXT-DECORATION: none
}
A:active {
COLOR: #a00000
}
A:hover {
COLOR: #000000; TEXT-DECORATION: none
}
</STYLE>
<STYLE>BODY {
SCROLLBAR-FACE-COLOR: #3a444f; SCROLLBAR-HIGHLIGHT-COLOR: #3a444f; SCROLLBAR-SHADOW-COLOR: #3a444f; SCROLLBAR-3DLIGHT-COLOR: #3a444f; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-TRACK-COLOR: #3a444f; SCROLLBAR-DARKSHADOW-COLOR: #3a444f
}
</STYLE>
<style>
<!--
BODY{
CURSOR: url(arrow.cur);
}
-->
</style>
<body>
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
$rows = 3;
$cols = 3;
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 0;
}
$num_pics = count($result_array);
$cells = $rows * $cols;
$pages = ceil($num_pics / ($rows * $cols));
$num_pages = $pages - 1;
$output = array();
$slices = array();
$push = 0;
$showpage = $page + 1;
for($k=0;$k<$pages;$k++)
{
array_push($slices, $push);
$push = $push + $cells;
}
for($k=0;$k<$pages;$k++)
{
if($page == key($slices))
{
$output = array_slice($result_array, current($slices), $cells);
}
next($slices);
}
reset($output);
print "<center>\n<table width='*' border='1' bordercolor='#000000' cellspacing='0' cellpadding='2'>\n";
for($i=0;$i<$rows;$i++)
{
print "\t<tr>\n";
for($j=0;$j<$cols;$j++)
{
if(current($output) != false)
{
$pic = current($output);
$size = getimagesize($dir.$pic);
$height_button = $size[1] + 70;
$value = current($output);
print "\t\t<td width='100' height='100' align=center>\n\t\t\t<a href=JavaScript:laatZien('$value',$height_button,$size[0],'$dir');>\n\t\t\t\t<img width='100' height='100' border='0' src='$dir$value'>\n\t\t\t</a>\n\t\t</td>\n\n";
next($output);
}
else
{
print "\t\t<td width='100' height='100' align='center'> </td>\n";
}
}
print "\t</tr>\n";
}
$ref = $_SERVER['PHP_SELF'];
print "</table>\n";
if($num_pages == '0')
{
print "<span>[ </span>";
print "vorige";
print "<span> ] </span>";
print "<span> [ </span>";
print "volgende";
print "<span> ]</span>";
}
elseif(($page == '0')||($page == ''))
{
$next = $page + 1;
print "<span>[ </span>";
print "vorige";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "<a href='$ref?page=$next'>volgende</a>";
print "<span> ]</span>";
}
elseif($page == $num_pages)
{
// geen next knopje, $pages = maximum
$prev = $page - 1;
print "<span>[ </span>";
print "<a href='$ref?page=$prev'>vorige</a>";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "volgende";
print "<span> ]</span>";
}
else
{
$next = $page + 1;
$prev = $page - 1;
print "<span>[ </span>";
print "<a href='$ref?page=$prev'>vorige</a>";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "<a href='$ref?page=$next'>volgende</a>";
print "<span> ]</span>";
}
print "<br><br>";
print "Pagina: $showpage van $pages";
?>
$rows = 3;
$cols = 3;
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 0;
}
$num_pics = count($result_array);
$cells = $rows * $cols;
$pages = ceil($num_pics / ($rows * $cols));
$num_pages = $pages - 1;
$output = array();
$slices = array();
$push = 0;
$showpage = $page + 1;
for($k=0;$k<$pages;$k++)
{
array_push($slices, $push);
$push = $push + $cells;
}
for($k=0;$k<$pages;$k++)
{
if($page == key($slices))
{
$output = array_slice($result_array, current($slices), $cells);
}
next($slices);
}
reset($output);
print "<center>\n<table width='*' border='1' bordercolor='#000000' cellspacing='0' cellpadding='2'>\n";
for($i=0;$i<$rows;$i++)
{
print "\t<tr>\n";
for($j=0;$j<$cols;$j++)
{
if(current($output) != false)
{
$pic = current($output);
$size = getimagesize($dir.$pic);
$height_button = $size[1] + 70;
$value = current($output);
print "\t\t<td width='100' height='100' align=center>\n\t\t\t<a href=JavaScript:laatZien('$value',$height_button,$size[0],'$dir');>\n\t\t\t\t<img width='100' height='100' border='0' src='$dir$value'>\n\t\t\t</a>\n\t\t</td>\n\n";
next($output);
}
else
{
print "\t\t<td width='100' height='100' align='center'> </td>\n";
}
}
print "\t</tr>\n";
}
$ref = $_SERVER['PHP_SELF'];
print "</table>\n";
if($num_pages == '0')
{
print "<span>[ </span>";
print "vorige";
print "<span> ] </span>";
print "<span> [ </span>";
print "volgende";
print "<span> ]</span>";
}
elseif(($page == '0')||($page == ''))
{
$next = $page + 1;
print "<span>[ </span>";
print "vorige";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "<a href='$ref?page=$next'>volgende</a>";
print "<span> ]</span>";
}
elseif($page == $num_pages)
{
// geen next knopje, $pages = maximum
$prev = $page - 1;
print "<span>[ </span>";
print "<a href='$ref?page=$prev'>vorige</a>";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "volgende";
print "<span> ]</span>";
}
else
{
$next = $page + 1;
$prev = $page - 1;
print "<span>[ </span>";
print "<a href='$ref?page=$prev'>vorige</a>";
print "<span> ] </span>";
$page_link = 1;
for($k=0;$k<$pages;$k++)
{
if($k == $page)
{
print "$page_link ";
}
else
{
print "<a href='$ref?page=$k'>$page_link</a> ";
}
$page_link++;
}
print "<span> [ </span>";
print "<a href='$ref?page=$next'>volgende</a>";
print "<span> ]</span>";
}
print "<br><br>";
print "Pagina: $showpage van $pages";
?>
</center>
</body>
</html>
$next = $fotonr + 1;
$previous = false;
}
elseif ($fotonr > $num_pics) {
$next = false;
$previous = $fotonr - 1;
}
else {
$next = $fotonr + 1;
$previous = $fotonr - 1;
}
if($previous != false) {
echo("link naar foto " . $previous);
}
if($next != false) {
echo("link naar foto " . $next);
}
Het script is nl. niet van mezelf.
ik heb er even naar gekeken dan moet je wel het hele script omgooien...
Een andere oplossing is er zeker niet...