Ik probeer door een array heen te wandelen voor een vorige - volgende button maar ik zie iets over het hoofd.
Ik heb een multidemensionale array bijv:
Array
(
[3] => Array
(
[id] => 3
[cat_id] => 9
[description] => Hier dan een beschrijving
[date_ne] => 27-12-2006 om 14:48
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/3_big.jpg
[image_width] => 640
[image_height] => 437
)
[image_small] => Array
(
[image_name] => images/3_small.jpg
[image_width] => 150
[image_height] => 102
)
)
)
[4] => Array
(
[id] => 4
[cat_id] => 9
[description] => asdasdas
[date_ne] => 27-12-2006 om 16:14
[cat_name] => Porsche boxtor
[images] => Array
(
[image_name] => Array
(
[image_name] => images/4_cat_cat.jpg
[image_width] => 200
[image_height] => 125
)
[image_big] => Array
(
[image_name] => images/4_big.jpg
[image_width] => 800
[image_height] => 521
)
[image_small] => Array
(
[image_name] => images/4_small.jpg
[image_width] => 150
[image_height] => 98
)
)
)
[5] => Array
(
[id] => 5
[cat_id] => 9
[description] => motor
[date_ne] => 27-12-2006 om 16:41
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/5_big.jpg
[image_width] => 800
[image_height] => 533
)
[image_small] => Array
(
[image_name] => images/5_small.jpg
[image_width] => 150
[image_height] => 100
)
)
)
[6] => Array
(
[id] => 6
[cat_id] => 9
[description] => adasdasd<br /><br />leendert
[date_ne] => 27-12-2006 om 16:57
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/6_big.jpg
[image_width] => 640
[image_height] => 376
)
[image_small] => Array
(
[image_name] => images/6_small.jpg
[image_width] => 150
[image_height] => 88
)
)
)
)
en deze code:
Wanneer ik bij de eerste photo op volgende klikt komt die bij index5 uit en hij slaat index4 dus over. als ik dan vanuit index5 terug doe gaat die weer naar 3 en de volgende knop staat er ook niet terwijl die er wel moet staan omdat index6 er nog achter staat.
Wat doe ik fout met prev() en next() ?
Ik heb een multidemensionale array bijv:
Array
(
[3] => Array
(
[id] => 3
[cat_id] => 9
[description] => Hier dan een beschrijving
[date_ne] => 27-12-2006 om 14:48
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/3_big.jpg
[image_width] => 640
[image_height] => 437
)
[image_small] => Array
(
[image_name] => images/3_small.jpg
[image_width] => 150
[image_height] => 102
)
)
)
[4] => Array
(
[id] => 4
[cat_id] => 9
[description] => asdasdas
[date_ne] => 27-12-2006 om 16:14
[cat_name] => Porsche boxtor
[images] => Array
(
[image_name] => Array
(
[image_name] => images/4_cat_cat.jpg
[image_width] => 200
[image_height] => 125
)
[image_big] => Array
(
[image_name] => images/4_big.jpg
[image_width] => 800
[image_height] => 521
)
[image_small] => Array
(
[image_name] => images/4_small.jpg
[image_width] => 150
[image_height] => 98
)
)
)
[5] => Array
(
[id] => 5
[cat_id] => 9
[description] => motor
[date_ne] => 27-12-2006 om 16:41
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/5_big.jpg
[image_width] => 800
[image_height] => 533
)
[image_small] => Array
(
[image_name] => images/5_small.jpg
[image_width] => 150
[image_height] => 100
)
)
)
[6] => Array
(
[id] => 6
[cat_id] => 9
[description] => adasdasd<br /><br />leendert
[date_ne] => 27-12-2006 om 16:57
[cat_name] => Porsche boxtor
[images] => Array
(
[image_big] => Array
(
[image_name] => images/6_big.jpg
[image_width] => 640
[image_height] => 376
)
[image_small] => Array
(
[image_name] => images/6_small.jpg
[image_width] => 150
[image_height] => 88
)
)
)
)
en deze code:
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
| <?php $photos =& $oPhoto->getPhotos(0, $_GET['cat']); $next = null; $prev = null; $countPhotos = count($photos); $count = 0; reset($photos); foreach ($photos as $key => $photo) { if ($key == $_GET['oid']) { if (next($photos)) $next = next($photos); if (prev($photos)) $prev = prev($photos); printf(' <table> <tr> <tr> <td> %s %s %s </td> </tr> <td> <img src="../../photoalbum/%s" alt="" /> </td> </tr> </table> ', ($count > 0) ? sprintf('<a href="?cat=%d&oid=%d"><< vorige </a>', $_GET['cat'], $prev['id']) : '', ($prev['id'] != $_GET['oid'] && $next['id'] != $_GET['oid']) ? ' | ' : '', ($count < $countPhotos) ? sprintf('<a href="?cat=%d&oid=%d">volgende >></a>', $_GET['cat'], $next['id']) : '', $photo['images']['image_big']['image_name'] ); break; } $count++; } ?> |
Wanneer ik bij de eerste photo op volgende klikt komt die bij index5 uit en hij slaat index4 dus over. als ik dan vanuit index5 terug doe gaat die weer naar 3 en de volgende knop staat er ook niet terwijl die er wel moet staan omdat index6 er nog achter staat.
Wat doe ik fout met prev() en next() ?