Bonjour,
Après de nombreuses recherches sur Internet et différentes versions de code testées je me tourne vers vous pour m'aider. Voici ma demande :
Je cherche à faire de la pagination, donc j'interroge ma base de données sur une requête de l'utilisateur et après je suis sensé afficher 10 tuples et passer à la page suivante.
De tous les codes que j'ai essayé, j'arrive à obtenir une pagination, mais dès que je clique sur la page 2, il n'y a plus de requêtes...
Je suppose que mon code est aussi très mauvais ><
Voici mon code :
Je vous remercie d'avance !
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
87
88
89
90
91
92
93
94
95
96
97
98
99 <?php $recherche = $_POST['recherche']; // on se connecte à notre base $connexion = mysql_connect("xxxxxxxxxxx","xxxxxxxxxxxxx","xxxxxxxxxx") or die(mysql_error()); mysql_select_db('xxxxxxx') or die(mysql_error()); //ouverture du tableau qui va afficher le résultat if($_POST['recherchemod'] == 'nom') { $sq1 = "SELECT * from mods WHERE nom = '$recherche'"; $requete = mysql_query($sq1); while ($recherche2 = mysql_fetch_array($requete)) { echo "<table class=\"table table-striped table-bordered\"><tbody>"; print "<tr><td><b>$recherche2[nom]</b></td>"; print "<td width=150 rowspan=\"4\" colspan=\"1\"><img src=\"$recherche2[image]\" width=150 height=80</img><br/></td></tr>"; print "<tr><td><b>Material needed :</b><br>".nl2br($recherche2['materiel'])."</td></tr>"; print "<tr><td><b>Weight class : </b>$recherche2[poids]</td></tr>"; print "<tr><td><b>Link : </b><a href=\"$recherche2[lien]\">$recherche2[nom]</a></td></tr>"; echo "</tbody></table><br>"; } } //2éme condition si l'user choisi par corps elseif($_POST['recherchemod'] == 'corps') { $sq1 = "SELECT * from mods WHERE corps = '$recherche'"; $requete = mysql_query($sq1); while ($recherche2 = mysql_fetch_array($requete)) { echo "<table class=\"table table-striped table-bordered\"><tbody>"; print "<tr><td><b>$recherche2[nom]</b></td>"; print "<td width=150 rowspan=\"4\" colspan=\"1\"><img src=\"$recherche2[image]\" width=150 height=80</img><br/></td></tr>"; print "<tr><td><b>Material needed :</b><br>".nl2br($recherche2['materiel'])."</td></tr>"; print "<tr><td><b>Weight class : </b>$recherche2[poids]</td></tr>"; print "<tr><td><b>Link : </b><a href=\"$recherche2[lien]\">$recherche2[nom]</a></td></tr>"; echo "</tbody></table><br>"; } } //3éme condition par caps elseif($_POST['recherchemod'] == 'caps') { $sq1 = "SELECT * from mods WHERE caps = '$recherche'"; $requete = mysql_query($sq1); while ($recherche2 = mysql_fetch_array($requete)) { echo "<table class=\"table table-striped table-bordered\"><tbody>"; print "<tr><td><b>$recherche2[nom]</b></td>"; print "<td width=150 rowspan=\"4\" colspan=\"1\"><img src=\"$recherche2[image]\" width=150 height=80</img><br/></td></tr>"; print "<tr><td><b>Material needed :</b><br>".nl2br($recherche2['materiel'])."</td></tr>"; print "<tr><td><b>Weight class : </b>$recherche2[poids]</td></tr>"; print "<tr><td><b>Link : </b><a href=\"$recherche2[lien]\">$recherche2[nom]</a></td></tr>"; echo "</tbody></table><br>"; } } //4éme condition par poids elseif($_POST['recherchemod'] == 'poids') { $sq1 = "SELECT * from mods WHERE poids = '$recherche'" ; $requete = mysql_query($sq1); while ($recherche2 = mysql_fetch_array($requete)) { echo "<table class=\"table table-striped table-bordered\"><tbody>"; print "<tr><td><b>$recherche2[nom]</b></td>"; print "<td width=150 rowspan=\"4\" colspan=\"1\"><img src=\"$recherche2[image]\" width=150 height=80</img><br/></td></tr>"; print "<tr><td><b>Material needed :</b><br>".nl2br($recherche2['materiel'])."</td></tr>"; print "<tr><td><b>Weight class : </b>$recherche2[poids]</td></tr>"; print "<tr><td><b>Link : </b><a href=\"$recherche2[lien]\">$recherche2[nom]</a></td></tr>"; echo "</tbody></table><br>"; } } elseif($_POST['recherchemod'] == 'type') { $sq1 = "SELECT * from mods WHERE type = '$recherche'"; $requete = mysql_query($sq1); while ($recherche2 = mysql_fetch_array($requete)) { echo "<table class=\"table table-striped table-bordered\"><tbody>"; print "<tr><td><b>$recherche2[nom]</b></td>"; print "<td width=150 rowspan=\"4\" colspan=\"1\"><img src=\"$recherche2[image]\" width=150 height=80</img><br/></td></tr>"; print "<tr><td><b>Material needed :</b><br>".nl2br($recherche2['materiel'])."</td></tr>"; print "<tr><td><b>Weight class : </b>$recherche2[poids]</td></tr>"; print "<tr><td><b>Link : </b><a href=\"$recherche2[lien]\">$recherche2[nom]</a></td></tr>"; echo "</tbody></table><br>"; } } mysql_close(); ?> <div class="pagination"> <ul> <li><a href="#">Prev</a></li> <li class="active"> <a href="#">1</a> </li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">Next</a></li> </ul> </div>
Partager