Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 03/05/2011, 10h23   #1
Invité de passage
 
Homme
Etudiant
Inscription : mai 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Etudiant
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : mai 2011
Messages : 2
Points : 1
Points : 1
Par défaut php - pagination -phpmesfilms

Bonjour,
J'utilise actuellement le petit script "phpmesfilms 1.5".
J'ai effectué quelques modifications dans le script afin de l'adapter à mes besoins, et jusque là tout va bien.
Je souhaite maintenant mettre en place un système de pagination car le script "balance" directement tout le contenu de la base de données sur une page, ce qui me pose des problème.
Et là je bloque TOTALEMENT...j'ai fait de nombreux essais, mais rien...
Si quelqu'un voit une solution, je suis preneur !
Je vous met ci-dessous l'extrait du script php qui génère la page, ainsi que sa page html associée
- extrait de index.php :

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
 
 
function listerFilms() 
 
 { 
 
     if(!empty($_REQUEST['id'])) 
 
  { 
 
   detailerFilm(); 
 
   return; 
 
  } 
 
 
 
  connectionBDD(); 
 
 
 
  // gestion du tri 
 
  $trierPar = getValeur("trierPar","titre"); 
 
  $ordre = getValeur("ordre","ASC"); 
$compte = 0; 
 
  switch($trierPar) 
 
  { 
 
   case "categorie": $tri="categorie";   break; 
 
   case "titre":  $tri="titre";    break; 
 
   case "annee":  $tri="annee";    break; 
 
   case "note":  $tri="note";    break; 
 
   case "realisateur": $tri="realisateur";   break; 
 
   case "acquisition": $tri="id";$ordre="DESC"; break; 
 
   default:   $tri="titre"; 
 
  } 
 
 
 
  // champ de selection des categories 
 
     $listeCategories = creerListeCategorie();  
 
 
  // recherche de la liste des films 
 
  if(!$listeFilms = recupererRequete("SELECT films.id id,titre,annee,note,illustration,realisateur,intitule categorie FROM ".PREFIX_BDD."films as films, ".PREFIX_BDD."categories as categories WHERE categories.id = films.categorie ORDER By ".$tri." ".$ordre)) 
 
 
  { 
 
   $listeFilms = ""; 
 
  } 
 
  else 
 
  { 
 
    for($i=0;$i<count($listeFilms);$i++) 
 
    { 
 
     $listeFilms[$i]['titre'] = htmlspecialchars(stripslashes($listeFilms[$i]['titre']),ENT_QUOTES); 
 
    $listeFilms[$i]['lettre'] = strtoupper(substr($listeFilms[$i]['titre'],0,1));     
 
    }   
 
  } 
 
 
 
  // nombre de films recupérés 
 
  $nbFilms = count($listeFilms); 
 
 
  // appel du gabarit 
 
  include "gabarits/principal.html"; 
 
 
 
 
  deconnectionBDD(); 
 
 }
- La page html associée :
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
 
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">--> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 
<html> 
 
 <head> 
 
  <title>PhpMesFilms - Liste</title> 
 
  <link rel="stylesheet" type="text/css" href="styleGeneral.css" media="screen" title="Normal" /> 
 
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
 
  <script language="javascript" src="script.js" type="text/javascript"></script> 
 
 </head> 
 
 <body> 
 
  <div id="conteneur"> 
 
   <h1>/ VIDEOTHEQUE</h1> 
 
   <div id="texte"> 
 
    <form name="recherche" method="post" action="index.php"> 
 
     <table width="578" class="blocTxt"> 
 
      <tr> 
 
       <td> 
 
Recherche par : 
 
        <input type="text" name="mot" value="" onfocus="cleanRecherche();" /> 
 
 
 
        <select name="categorie" onfocus="cleanRecherche();"> 
 
         <?php echo $listeCategories."\n"; ?> 
 
        </select> 
 
        <input type="button" value="CHERCHER" onclick="rechercher();"/> 
 
        <input type="hidden" name="monAction" value="rechercherFilm" /> 
 
       </td> 
 
       <td align="right"> 
 
        <div id="btVideotheque"> 
 
         <a href="#" onclick="mesChoix();"><img src="images/bt_choisir.png" alt="" border="0" title="mes choix"/></a> 
 
         <a href="admin/index.php"><img src="images/bt_admin.png" alt="" border="0" title="administration"/></a> 
 
        </div> 
 
       </td> 
 
      </tr> 
 
     </table>   
 
    </form>    
 
    <?php if(empty($listeFilms)) { ?> 
 
     <div class="blocTxt"> 
 
      <h2>Aucun film n'est présent dans la base !</h2> 
 
     </div> 
 
     <?php } else { ?> 
 
     <select style="float:right;" onchange="trierListeFilms(this.value);"> 
 
      <option value="0">- Tri spéciaux -</option> 
 
      <option value="acquisition" <?php if($trierPar=='acquisition') print 'selected'; ?>>les plus récemment acquis</option> 
 
     </select> 
 
     <h2><?php print $nbFilms; ?> film(s) au total !!</h2> 
 
     <?php if($tri=="titre") { ?> 
 
     <div name="spacer" style="height:10px;"></div> 
 
     <div align="center"> 
 
      <a href="#A">A</a> 
 
      <a href="#B">B</a> 
 
      <a href="#C">C</a> 
 
      <a href="#D">D</a> 
 
      <a href="#E">E</a> 
 
      <a href="#F">F</a> 
 
      <a href="#G">G</a> 
 
      <a href="#H">H</a> 
 
      <a href="#I">I</a> 
 
      <a href="#J">J</a> 
 
      <a href="#K">K</a> 
 
      <a href="#L">L</a> 
 
      <a href="#M">M</a> 
 
      <a href="#N">N</a> 
 
      <a href="#O">O</a> 
 
      <a href="#P">P</a> 
 
      <a href="#Q">Q</a> 
 
      <a href="#R">R</a> 
 
      <a href="#S">S</a> 
 
      <a href="#T">T</a> 
 
      <a href="#U">U</a> 
 
      <a href="#V">V</a> 
 
      <a href="#W">W</a> 
 
      <a href="#X">X</a> 
 
      <a href="#Y">Y</a> 
 
      <a href="#Z">Z</a> 
 
     </div> 
 
     <?php } ?> 
 
     <div name="spacer" style="height:10px;"></div> 
 
     <div class="listeFilms"> 
 
     <table width="578" cellspacing="0"> 
 
      <thead> 
 
       <tr> 
 
        <td><a href="#" onclick="trierListeFilms('titre');">Titre</a></td> 
 
        <td style="text-align:center;"><a href="#" onclick="trierListeFilms('categorie');">Catégorie</a></td> 
 
        <td style="text-align:center;"><a href="#" onclick="trierListeFilms('annee');">Année</a></td> 
 
        <td style="text-align:center;"><a href="#" onclick="trierListeFilms('realisateur');">Réalisateur</a></td> 
 
        <td style="text-align:center;"><a href="#" onclick="trierListeFilms('note');">Note (/10)</a></td> 
 
       </tr> 
 
      </thead> 
 
      <tbody> 
 
     <?php $lettreCourante='@'; ?> 
 
     <?php foreach($listeFilms as $unFilm) {  ?> 
 
       <tr> 
 
 
 
 
 
 
 
 
 
 
 
        <td class="tdTexte"><?php if(strcmp($lettreCourante,$unFilm['lettre'])<0) { ?><a id="<?php print $unFilm['lettre'] ?>"></a><?php } ?> 
 
 
 
 
<!-- vignettes miniatures --> 
 
<a href="index.php?id=<php print $unFilm['id'] ?>" class="info"><?php print $unFilm['titre'] ?><span><img src="illustrations/<?php print $unFilm['illustration'] ?>" alt="<?php print $unFilm['titre'] ?>" width="130px" height="180px" /></span></a></td> 
 
 
 
 
 
        <td style="text-align:center;" class="tdTexte"><?php print $unFilm['categorie'] ?></td> 
 
        <td style="text-align:center;" class="tdTexte"><?php print $unFilm['annee'] ?></td> 
 
        <td style="text-align:center;" class="tdTexte"><?php print $unFilm['realisateur'] ?></td> 
 
        <td style="text-align:center;" class="tdTexte"><?php print $unFilm['note'] ?></td> 
 
      </tr> 
 
       <tr> 
 
        <td bgcolor="#A3C1FF" colspan="5" height="1" class="tdSpacer"><img src="images/spacer.gif" width="1" height="1" border=0 /></td> 
 
       </tr> 
 
 
 
 
 
 
     <?php } ?> 
 
      </tbody> 
 
 
     </table> 
 
     </div> 
 
    <?php } ?> 
 
 
 
   </div> 
 
 
 
   <div id="pied"> 
 
    powered by Shmils 
 
   </div> 
 
  </div> 
 
  <form name="trierFilms" id="trierFilms" action="index.php" method="post"> 
 
   <input type="hidden" name="trierPar" value="<?php print $tri ?>" /> 
 
   <input type="hidden" name="ordre" value="<?php print $ordre ?>" /> 
 
  </form> 
 
  <form name="detailFilm" id="detailFilm" action="index.php" method="post"> 
 
   <input type="hidden" name="monAction" value="detailerFilm" /> 
 
   <input type="hidden" name="id" value="" /> 
 
  </form> 
 
  <form name="choix" id="choix" action="index.php" method="post"> 
 
   <input type="hidden" name="monAction" value="" /> 
 
  </form> 
 
 </body> 
 
</html>
Par avance, merci.
cneil1 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 01h38   #2
Membre régulier
 
Inscription : juin 2008
Messages : 105
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 105
Points : 84
Points : 84
Salut, tu pourrais faire une requête dans laquelle tu limites les résultats à 10 (ou x selon tes besoins) enreg. par page, avec des commandes pg suivante, précédente, début et fin par ex.

Alpha.
alpha232 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 10h03   #3
Membre chevronné
 
Avatar de Elwyn
 
Homme
Ingénieur systèmes et réseaux
Inscription : juillet 2006
Messages : 836
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Ingénieur systèmes et réseaux

Informations forums :
Inscription : juillet 2006
Messages : 836
Points : 712
Points : 712
Bonjour,

il y a beaucoup énormément de script de pagination sur Internet. Tu trouveras forcément celui qui te convient

NB : La première recherche Google pointe sur un article de Developpez.com, le voici.
__________________
Dire Straits, Bob Dylan, Led Zeppelin, the Who, Pink Floyd, AC/DC, Guns & Roses, the Doors, ...
Elwyn est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/05/2011, 11h15   #4
Invité de passage
 
Homme
Etudiant
Inscription : mai 2011
Messages : 2
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Etudiant
Secteur : Agroalimentaire - Agriculture

Informations forums :
Inscription : mai 2011
Messages : 2
Points : 1
Points : 1
Par défaut c'est bon !

Je viens de m'en sortir.

Un grand merci à ceux qui ce sont penchés sur la question !
cneil1 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 07h31.


 
 
 
 
Partenaires

Hébergement Web