Bonjour à tous,
Voici mon code :
Le problème ce trouve en bas du code avec la fonction while, while m'affiche tout les pages et j'aimerais afficher juste 20 pages par 20 et ne pas tout afficher d'un seul coup.
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 <?php $nbsujet = 50; if ($page ==""){$page = 1 ;} ?> <?php echo '<table width="750" border="0" align="center" cellpadding="4" cellspacing="0"> <tr><td><a href=""><font size="1" color="#454545">Accueil</a> > '.$_GET['region'].' > '.$_GET['categorie'].'</font></td></tr></table><br>'; $dir2 = opendir(''.$_GET['region'].'/'.$_GET['categorie'].'/annonce/'); $tableau = array(); $i=0; while ($File = readdir($dir2)){ if($File != "." && $File != ".." && $File != "" && $File != ".htaccess" && $File != "moteur.php" && $File != "index.php" && $File != "index.html") { $tableau[] = ''.$_GET['region'].'/'.$_GET['categorie'].'/annonce/'.$File.''; } $i++; } closedir($dir2); rsort($tableau); $Max = count($tableau); $pagemin = $page*$nbsujet-$nbsujet; $nbpage = $Max/$nbsujet; $nbpage = ceil($nbpage); if ($page == $nbpage) {$pagemax = $Max;} else {$pagemax = $page*$nbsujet;} if ($Max != 0){ for($i = $pagemin; $i != $pagemax; $i++){ include "$tableau[$i]"; } } ?> <table width="750" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> <?php $nbpage = $Max/$nbsujet; $nbpage = ceil($nbpage); $nbpage2 = $nbpage +1 ; while ($nbpage != 0){ $nbpage3 = $nbpage2 - $nbpage; echo '<a href=moteur.php?region='.$_GET['region'].'&categorie='.$_GET['categorie'].'&page='.$nbpage3.'&search='.$_GET['search'].'> '.$nbpage3.' </a>'; $nbpage = $nbpage - 1 ; } ?> </b></td> </tr> </table>
J'ouvre un répertoire avec opendir ex: j'ai 10 000 sujet à afficher le script m'en affiche 50 et créer ensuite une pages 1 2 3 etc..
j'aimerais avec une fonction while ou if ou autre en afficher que 20 par 20 et non pas tout les liens.
Partager