Bonjour
Habituellement j'inclus un bouton checkbox qui affiche une nouvelle page suivant le mois sélectionner avec 2 nouvelles requêtes!
Pour éviter d'avoir 12 pages différentes, on m'a transmis un script pour avoir un bouton checkbox qui exécute des requêtes.
Mais je ne sais pas trop comment l'adapter
Code html :
Code html : 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 <title>test</title> <head> <script src="jquery-1.11.0.js" type="text/javascript"></script> </head> <div id="test"> </div> <table width="100%"> <tr> <td> <form name="formulaire3"> Mois de: <select name="mois"> <option selected="selected">janvier</option> <option>fevrier</option> <option>mars</option> <option>avril</option> <option>mai</option> <option>juin</option> <option>juillet</option> <option>aout</option> <option>septembre</option> <option>octobre</option> <option>novembre</option> <option>decembre</option> </select> </form></td> </tr> </table> <br />
Code :
Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 $(function () { var choix= this.selectedIndex; $.get( "tab.php?choix=1", function( data ) { $('#test').html(data); }); }); $( "select" ).change(function () { var choix= this.selectedIndex+1; $.get( "tab.php?choix="+choix, function( data ) { $('#test').html(data); }); });
Fichier: tab.php
Un petit coup de main SVP.
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
100
101
102
103
104
105 <?php if (isset( $_GET['choix'])) { $devis = $_GET['choix']; } // on lance la requête pour récupérer les enregistrements correspondants au numéro de page courante $query = "SELECT * FROM devis".$devis." WHERE qte<50 ORDER BY id_devis DESC"; echo $query;exit; $resultat = mysql_query ($query) or die('pb de connexion ?'); // tant qu'il y a un enregistrement, les instructions dans la boucle s'exécutent ?> <h3>- de 50 véhicules</h3> <?php echo "<table class='full list'>"; echo "<tr>"; echo "<th align='center' width='2%'>id</th>"; echo "<th align='center' width='9%'>Date</th>"; echo "<th align='center' width='2%'>Qte</th>"; echo "<th align='center' width='10%'>Type</th>"; echo "<th align='center' width='10%'>Délai</th>"; echo "<th align='center' width='10%'>Nom</th>"; echo "<th align='center' width='10%'>Prénom</th>"; echo "<th align='center' width='10%'>Fonction</th>"; echo "<th align='center' width='10%'>Société</th>"; echo "<th align='center' width='7%'>CP</th>"; echo "<th align='center' width='10%'>Email</th>"; echo "<th align='center' width='10%'>Téléphone</th>"; echo "</tr>"; while ($ligne = mysql_fetch_assoc($resultat)) { echo "<tr>"; echo "<td align='center' width=''>".$ligne['id_devis']."</td>"; echo "<td align='center' width=''>".$ligne['date']."</td>"; echo "<td align='center' width=''>".$ligne['qte']."</td>"; echo "<td align='center' width=''>".$ligne['type']."</td>"; echo "<td align='center' width=''>".$ligne['delai']."</td>"; echo "<td align='center' width=''>".$ligne['nom']."</td>"; echo "<td align='center' width=''>".$ligne['prenom']."</td>"; echo "<td align='center' width=''>".$ligne['fonction']."</td>"; echo "<td align='center' width=''>".$ligne['societe']."</td>"; echo "<td align='center' width=''>".$ligne['cp']."</td>"; echo "<td align='center' width=''>".$ligne['mail']."</td>"; echo "<td align='center' width=''>".$ligne['tel']."</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='12'><span style='font-weight: bold'>Commentaires : </span>".$ligne['contenu']."</td>"; echo "</tr>"; } echo "</table>"; if(isset($erreur)) echo $erreur; // on lance la requête pour récupérer les enregistrements correspondants au numéro de page courante $query2 = "SELECT * FROM devis".$devis." WHERE qte>50 ORDER BY id_devis DESC"; $resultat2 = mysql_query ($query2) or die('pb de connexion ?'); // tant qu'il y a un enregistrement, les instructions dans la boucle s'exécutent ?> <h3>+ de 50 véhicules</h3> <?php echo "<table class='full list'>"; echo "<tr>"; echo "<th align='center' width='2%'>id</th>"; echo "<th align='center' width='9%'>Date</th>"; echo "<th align='center' width='2%'>Qte</th>"; echo "<th align='center' width='10%'>Type</th>"; echo "<th align='center' width='10%'>Délai</th>"; echo "<th align='center' width='10%'>Nom</th>"; echo "<th align='center' width='10%'>Prénom</th>"; echo "<th align='center' width='10%'>Fonction</th>"; echo "<th align='center' width='10%'>Société</th>"; echo "<th align='center' width='7%'>CP</th>"; echo "<th align='center' width='10%'>Email</th>"; echo "<th align='center' width='10%'>Téléphone</th>"; echo "</tr>"; while ($ligne2 = mysql_fetch_assoc($resultat2)) { echo "<tr>"; echo "<td align='center' width=''>".$ligne2['id_devis']."</td>"; echo "<td align='center' width=''>".$ligne2['date']."</td>"; echo "<td align='center' width=''>".$ligne2['qte']."</td>"; echo "<td align='center' width=''>".$ligne2['type']."</td>"; echo "<td align='center' width=''>".$ligne2['delai']."</td>"; echo "<td align='center' width=''>".$ligne2['nom']."</td>"; echo "<td align='center' width=''>".$ligne2['prenom']."</td>"; echo "<td align='center' width=''>".$ligne2['fonction']."</td>"; echo "<td align='center' width=''>".$ligne2['societe']."</td>"; echo "<td align='center' width=''>".$ligne2['cp']."</td>"; echo "<td align='center' width=''>".$ligne2['mail']."</td>"; echo "<td align='center' width=''>".$ligne2['tel']."</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='12'><span style='font-weight: bold'>Commentaires : </span>".$ligne2['contenu']."</td>"; echo "</tr>"; } echo "</table>"; if(isset($erreur)) echo $erreur;
Partager