Bonjour voila mon problème je voudrais faire une pagination sur ma table.
La requête fonctionne (tester)
Le problème est que lorsque je mets le code pour la pagination il n'y a que "Page : " qui est afficher sur la page index.php et je ne trouve pas l'erreur
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
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 <?php include('connexion.inc'); ?> <html> <head> <title>Info-commune</title> </head> <body> <?php $messagesParPage=15; $retour_total=pg_query('SELECT COUNT(*) AS total FROM communes'); $donnees_total=pg_fetch_assoc($retour_total); $total=$donnees_total['total']; $nombreDePages=ceil($total/$messagesParPage); if(isset($_GET['page'])) { $pageActuelle=intval($_GET['page']); if($pageActuelle>$nombreDePages) { $pageActuelle=$nombreDePages; } } else { $pageActuelle=1; } $premiereEntree=($pageActuelle-1)*$messagesParPage; $req = $connexion->prepare("SELECT * FROM communes Where nom like '$cherchnom%'or dept='$cherchdep' or region = '$cherchreg' LIMIT '.$premiereEntree.', '.$messagesParPage.' "); $req->execute(); $req->setFetchMode(PDO::FETCH_ASSOC); $Idd = 1; while ($affichage = $req->fetchObject()) { ?> <table> <thead> <tr> <td><font size="2" ><b>N°</b></font></td> <td><font size="2" ><b>Nom</b></font></td> <td><font size="2" ><b>Population</b></font></td> <td><font size="2" ><b>Departement</b></font></td> <td><font size="2" ><b>N° commune</b></font></td> <td><font size="2" ><b>Région</b></font></td> </tr> </thead> <tr> <td><?php echo $Idd ?></td> <td><?php echo '<a href="recherche.php?nom_ascii_maj='.$affichage->nom_ascii_maj.'®ion='.$affichage->region.'&population='.$affichage->population.'&departement='.$affichage->dept ?>"><?php echo $affichage->nom_ascii_maj ?></a></td> <td><?php echo $affichage->population ?></td> <td><?php echo $affichage->dept ?></td> <td><?php echo $affichage->comm ?></td> <td><?php echo $affichage->region ?></td> </tr> <?php $Idd = $Idd + 1; } ?> </table> <?php echo '<p align="center">Page : '; for($i=1; $i<=$nombreDePages; $i++) { if($i==$pageActuelle) { echo ' [ '.$i.' ] '; } else { echo ' <a href="index.php?page='.$i.'">'.$i.'</a> '; } } echo '</p>'; ?> </body> </html>
Partager