bonjour,
j'ai un dossier avec des photos, j'ai fais mon code pour afficher les photos de ce dossier mais je souhaiterais ajouter une pagiation
de facon a n'afficher que 50 photos par page,
voici mon code :
merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php $tableau = array(); $dossier = opendir ('./pics/'); while ($fichier = readdir ($dossier)) { if ($fichier != '.' && $fichier != '..' && $fichier != 'index.php') { $tableau[] = $fichier; } } closedir ($dossier); $nbcol=5; $nbpics = count($tableau); if ($nbpics != 0) { echo '<table>'; for ($i=0; $i<$nbpics; $i++){ if($i%$nbcol==0) echo '<tr>'; echo '<td><a rel="example_group" href="pics/' , $tableau[$i] , '" ><img src="mini.php?f=' , $tableau[$i] , '" alt="Image" width="200px" height="120px"/></a></td>'; if($i%$nbcol==($nbcol-1)) echo '</tr>'; } echo '</table>'; } else echo 'Aucune image a* afficher'; ?>
alors j'ai regardé un peu, j'arrive a faire fonctionner mais ce n'est pas correct au niveau de l'affichage, j'ai fais comme ca
la premiere page est index.php hors dès que je l'ouvre je n'est pas de photo, si je clique sur le 1 de la pagination je les ai,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 $tableau = array(); $dossier = opendir ('./pics/'); while ($fichier = readdir ($dossier)) { if ($fichier != '.' && $fichier != '..' && $fichier != 'index.php') { $tableau[] = $fichier; } } closedir ($dossier); $nbcol=5; $nbpics = count($tableau); //definir le nombre d'image par page que l'on souhaite $pagination=29; $nombreDePages=ceil($nbpics/$pagination); if ($nbpics != 0) { echo '<table>'; for ($i = ($_GET['index']-1)*$pagination; $i <= ($_GET['index']*$pagination); $i++){ if($i%$nbcol==0) echo '<tr>'; echo '<td><a rel="example_group" href="pics/' , $tableau[$i] , '" ><img src="mini.php?f=' , $tableau[$i] , '" alt="Image" width="200px" height="120px"/></a></td>'; if($i%$nbcol==($nbcol-1)) echo '</tr>'; } echo '</table>'; for ($i = 1 ; $i <= $nombreDePages ; $i++) { echo '<a href="index.php?index=' . $i . '">' . $i . '</a> '; } } else echo 'Aucune image a* afficher'; ?>
1/ comment mettre la page 1 en index.php
ensuite j'ai 5 colonnes donc je souhaiterais 40 photos par page hors quand je vais page 2 il y a des trous dans la premiere colonne
merci








Répondre avec citation
Partager