Doel: Op de voorpagina van mijn website de laatste recties tonen met bij behorende link naar de foto.
Probleem: Krijg de link op 1 ding na, namelijk het ID van de foto, ik denk zelf dat het de volgende parameter moet zijn
Wat ik al heb is het volgende:
Het gaat dus om de echo met de link
De volledige code van mijn fotoalbum is:
Probleem: Krijg de link op 1 ding na, namelijk het ID van de foto, ik denk zelf dat het de volgende parameter moet zijn
code:
1
| $fotoArray[$_GET["fotoID"]] |
Wat ik al heb is het volgende:
code:
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
| <?
include("config.php");
if(is_dir($_GET['boek'])){
$originalPath = $_GET['boek'];
$path = $_GET['boek'];
$fotoArray = array();
$d = dir("$path");
while($entry=$d->read()) {
if(eregi(".jpg|.jpeg|.gif|.bmp|.png", $entry)){
ClearStatCache();
$foto = $path . "/" . $entry ;
$fotoArray[] = $foto;
}
}
$d->close();
}
$count = count($fotoArray);
$pathspatie = str_replace("_", " ", $originalPath);
$query = mysql_query("select * from fotosreacties ORDER BY id DESC LIMIT 0,5");
while($rij = mysql_fetch_object($query))
{
echo "<a href=\"album/album.php?page=album&boek=". $rij->boek . "&fotoID=". $fotoArray[$_GET["fotoID"]] . "\">". afkorten($rij->reactie,30) ."</a><br>";
}
?> |
Het gaat dus om de echo met de link
De volledige code van mijn fotoalbum is:
code:
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?
include("../config.php");
if(is_dir($_GET['boek'])){
// configuratie
$aantalFotos = 15; // aantal fotos per pagina
$originalPath = $_GET['boek']; //de map aangeroepen in de url
$path = $_GET['boek']; // path naar de foto
$fotoArray = array();
$d = dir("$path");
while($entry=$d->read()) {
if(eregi(".jpg|.jpeg|.gif|.bmp|.png", $entry)){
ClearStatCache();
$foto = $path . "/" . $entry ;
$fotoArray[] = $foto;
}
}
$d->close();
$count = count($fotoArray);
$pathspatie = str_replace("_", " ", $originalPath);
// reactie Plaatsen
if(isset($_POST["submitreactie"])){
$query = "insert into fotosreacties (boek,foto,naam,datum,reactie) values ";
$query .= "('" . $_GET['boek'] . "','" . $fotoArray[$_GET["fotoID"]] . "','" . $_POST["naam"] . "','" . time() . "','" . $_POST["reactie"] . "')";
if($result = mysql_query($query)){
echo "Je reactie is geplaatst";
} // end if
else {
echo "Sorry, je reactie kon niet geplaatst worden.";
} // end else
} // end if
// kijken hoeveel reacties iedere foto heeft
$reacties;
$query = "select foto from fotosreacties where boek = '" . $_GET['boek'] . "'";
if($result = mysql_query($query)){
while ($r = mysql_fetch_array($result)){
while ($foto = current($fotoArray)) {
if ($foto==$r["foto"]){
$key = key($fotoArray);
} // end if
next($fotoArray);
} // end while
if(!isset($reacties[$key])){
$reacties[$key] = 1;
} // end if
else {
$reacties[$key]++;
} // end else
reset($fotoArray);
} // end while
} // end if
?>
<html>
<head>
<title>Fotos</title>
</head>
<body>
<body bgcolor="#f4ffff">
<table width="100%"><tr><td align="center" width="100%">
<?
// 1 FOTO PER PAGINA
if((isset($_GET['fotoID'])) AND (intval($_GET['fotoID']>=0)) AND (intval($_GET['fotoID'] < $count))){
$showFoto = intval($_GET['fotoID']);
echo "<table width='40%'><tr><td colspan='3' align='center'><b>" . $pathspatie . "</b>
<br><br><small>Foto " . ($showFoto + 1) . " / " . $count . "</small></big></font> </td></tr><tr>";
echo "<tr><td colspan='3' align='center'><a href='" . $fotoArray[$showFoto] . "' target='_blanc'>[img]'"[/img]</a></td></tr>";
echo "<tr><td width='40%'>";
if($showFoto!=0){
$prevFoto = ($showFoto - 1);
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $prevFoto . "'>prev</a> ";
} // end if
echo "</td><td width='33%'>";
$pageNR = floor($_GET['fotoID'] / $aantalFotos);
$pageNR = $pageNR * 18;
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>list</a> ";
echo "</td><td align='right'>";
if($showFoto!=($count -1)){
$nextFoto = ($showFoto + 1);
echo "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $nextFoto . "'>next</a> ";
} // end if
echo "</td></tr></table>";
echo "<br><br><b>Reacties</b>";
$reacties;
$query = "SELECT * FROM fotosreacties where foto = '" . $fotoArray[$showFoto] . "' order by datum ASC";
if($result = mysql_query($query)){
if(mysql_numrows($result)==0){
echo "<br><br>Er zijn nog geen reacties<br><br>";
} // end if
else {
echo "<table width='40%' cellspacing='0' border='0' cellpadding='0'>";
echo "<tr><td colspan='2'><hr></td></tr>";
while ($r = mysql_fetch_array($result)){
echo "<tr><td><b>" . $r["naam"] . "</b> ";
echo "</td><td width='40%'><small>[ " . date("d/m/Y @ H:i",$r["datum"]) . " ]</small></td><tr>";
echo "<tr><td colspan='2'>" . $r["reactie"] . "</td></tr>";
echo "<tr><td colspan='2'><hr></td></tr>";
} // end while
echo "</table>";
} // end else
} // end if
echo "<form method='post' action=''>";
echo "<table>";
echo "<tr>";
echo "<td>Naam:<br><textarea name='naam'></textarea></td></tr>";
echo "<tr><td>Jouw Reactie:<br><textarea name='reactie' cols='30' rows='5'></textarea><br></td></tr>";
echo "<tr><td><input type='submit' name='submitreactie' value='Verzenden'></td></tr>";
echo "</table>";
echo "</form>";
} // end if
// X FOTOS PER PAGINA
else {
// configuratie
$clm = 3; // Aantal kolommen
$countFotos = count($fotoArray);
$thumbPath = $path . "/"; //Path naar thumps
$path2 = $path . "/";
echo "<br><table ><tr>";
echo "<td align='center' colspan='" . $clm . "'>";
// navigatie
$navigation;
if($countFotos < ($aantalFotos + 1)){
$begin = 0;
$eind = $countFotos;
} // end if
else {
$aantalPages = ceil($countFotos / $aantalFotos) ;
for($i=1; $i < $aantalPages + 1; $i++){
$pageNR = ($i - 1) * $aantalFotos;
if($pageNR==$_GET["vanafFoto"]){
$navigation .= "<small><font color='#990000'>" . $i . "</font></small> ";
}
else {
$navigation .= "<a href='?page=album&boek=" . $originalPath . "&vanafFoto=" . $pageNR . "'>" . $i . "</a> ";
}
} // end for
if((isset($_GET['vanafFoto'])) AND (intval($_GET['vanafFoto']>=0)) AND (intval($_GET['vanafFoto'] < $countFotos))){
$begin = intval($_GET['vanafFoto']);
if(($begin + $aantalFotos) <= $countFotos){
$eind = ($begin + $aantalFotos);
} // end if
else {
$eind = $countFotos;
} // end else
} // end if
else {
$begin = 0;
$eind = $aantalFotos;
} // end else
$countFotos = count($fotoArray);
// path naar echte foto
} // end else
echo "<table border='0' cellpadding='0' cellspacing='2'><tr><td ><b>" . $pathspatie . "</b> <small>(" . $count . ")</small>
<br><br><center><small>Pictures " . ($begin + 1) . " - " . $eind . "</small></center></td></tr></table>";
if(($begin - $aantalFotos) >= 0){
$navigation = "<a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin - $aantalFotos) . "'><</a> " . $navigation;
} // end if
if(($begin + $aantalFotos) < $count){
$navigation .= " <a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&vanafFoto=" . ($begin + $aantalFotos) . "'>></a>";
} // end if
echo $navigation . "<br><br>";
echo "</td></tr><tr>";
$fotonr = 1;
for($i=$begin; $i < $eind; $i++){
$thumb = str_replace($path2, $thumbPath, $fotoArray[$i]);
echo "<td align='center'><a href='" . $_SERVER['PHP_SELF'] . "?page=album&boek=" . $originalPath . "&fotoID=" . $i . "'>[img]'"[/img]<br>";
echo "<small>reacties (";
if($reacties[$i]==0){
echo "0";
} // end if
else {
echo $reacties[$i];
} // end else
echo ")</small>";
echo "</a></td>";
$fotonr++;
if($fotonr == ($clm + 1)){
echo "</tr>\n<tr>";
$fotonr = 1;
} // end if
} // end for
echo "</tr>";
echo "<td align='center' colspan='" . $clm . "'>";
echo $navigation;
echo "</td></tr><tr>";
echo "</table>";
} // end else if
} // end if
else {
echo "Dit fotoalbum bestaat niet";
} // end else
?>
</td></tr></table>
</body>
</html> |