Bonjour, je me présente je m'appelle Kevin.

Je viens de me mettre au développement et j'ai un petit soucis avec mon code.

J'aimerais changer ma requete sql par rapport a une liste deroulante avec fonction OnChange afin de filtrer les resultat de mon tableau

Exemple : Totalité des réservations dans le tableau Puis filtrer par membre et date de soiree

Voici mon code cela doit clocher au niveau de la fonction OnChange je pense

Code PHP : 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
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
<?php
include('config.php');
?>
<?php
date_default_timezone_set("Europe/Paris");
?>
 
<?php
$date = date("d-m-Y");
$heure = date("H:i");
?>
 
<?php
//On verifie si lutilisateur est connecte
if(isset($_SESSION['username']))
{
?>
 
    <?php
 
            //Sinon, on affiche les donnes a partir de la base de donnee
            $dnn = mysql_fetch_array(mysql_query('select username,password,nom,prenom,statut,facebook,tel,email,avatar from users where username="'.$_SESSION['username'].'"'));
            $username = htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8');
            $password = htmlentities($dnn['password'], ENT_QUOTES, 'UTF-8');
            $nom = htmlentities($dnn['nom'], ENT_QUOTES, 'UTF-8');
            $prenom = htmlentities($dnn['prenom'], ENT_QUOTES, 'UTF-8');
            $statut = htmlentities($dnn['statut'], ENT_QUOTES, 'UTF-8');
            $facebook = htmlentities($dnn['facebook'], ENT_QUOTES, 'UTF-8');
            $tel = htmlentities($dnn['tel'], ENT_QUOTES, 'UTF-8');
 
            $email = htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8');
            $avatar = htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8');
 
        //On affiche le formulaire
?>
 
<html>
    <head>
 
    <script type="text/javascript" src="../script.js"></script>
    </head>
        <link rel="stylesheet" type="text/css" href="../styleresa.css">
 
 
<div align="center">
    <div align="center">
            <div align="center">
                <table border="1" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
            <p align="center">
            <a href="../login/<?php echo $url_home; ?>">
                        <font color="#FFFFFF">
                        <img src="../images/banner.jpg" alt="Espace Membre" width="580" height="312" /></font></a></td>
                    </tr>
                    <tr>
                        <td>
        <div class="foot">
            <p align="center"><b><font color="#FFFFFF" face="Verdana">Mes
            réservations</font></b></p>
            <div align="center">
                <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr>
 
                    </tr>
                    <tr>
                        <td>
 
 
                            <?php
$sql2 = " SELECT nom FROM users order by nom";
$result = mysql_query($sql2) or die("Requete pas comprise");
 
echo "
  
  
<form name='RP'>
<table><tr><td>
<select name='nom' onChange='Lien()'>
<option>RP</option>"; 
while ($row=mysql_fetch_array($result))
{
echo"<option>$row[0]</option>";
}
echo"</select></td></tr>
</table>
  
  
</form>
";
?>
 
 
</td>
<td>
 
 
 
 
 
 
                        </td>
                        <td>
 
 
 
 
                        </td>
                    </tr>
                </table>
            </div>
            <p><font color="#FFFFFF"><?php
 
 
 
 
// Le nom de notre table
$tablename = 'reservation';
$tablename2 = 'users';
 
 
 
            // Tri sur colonne
            $tri_autorises = array('id','nom','client','dateresa','datesoiree','bouteille','bouteille2','places');
            $order_by = in_array($_GET['order'],$tri_autorises) ? $_GET['order'] : 'id';
 
 
            // Sens du tri
            $order_dir = isset($_GET['inverse']) ? 'DESC' : 'ASC';
 
 
                // Préparation de la requête
 
$sql = "SELECT * FROM {$tablename} WHERE 1=1 ";
 
if (isset($_POST['nom'])) {
   $sql .= ' AND nom= "' . mysql_real_escape_string($_POST['nom']) .'" ';
}
 
 
$sql .= " ORDER BY {$order_by} {$order_dir}";   
$result = mysql_query($sql);
 
 
 
// Notre fonction qui affiche les liens
function sort_link($text, $order=false)
{
    global $order_by, $order_dir;
 
    if(!$order)
        $order = $text;
 
    $link = '<a href="?order=' . $order;
    if($order_by==$order && $order_dir=='ASC')
        $link .= '&inverse=true';
    $link .= '"';
    if($order_by==$order && $order_dir=='ASC')
        $link .= ' class="order_asc"';
    elseif($order_by==$order && $order_dir=='DESC')
        $link .= ' class="order_desc"';
    $link .= '>' . $text . '</a>';
 
    return $link;
}
 
 
// Affichage tableau
?>
 
 
<table border="1" width="100%" cellspacing="0" bordercolor="#666666">
    <tr>
        <th><?php echo sort_link('Id', 'id') ?></th>
        <th><?php echo sort_link('Rp', 'nom') ?></th>
        <th><?php echo sort_link('Client', 'client') ?></th>
        <th><?php echo sort_link('DateResa', 'dateresa') ?></th>
        <th><?php echo sort_link('DateSoiree', 'datesoiree') ?></th>
        <th><?php echo sort_link('Bouteille', 'bouteille') ?></th>
        <th><?php echo sort_link('Bouteille2', 'bouteille2') ?></th>
        <th><?php echo sort_link('Places', 'places') ?></th>
    </tr>
<?php while( $row=mysql_fetch_assoc($result) ) : ?>
    <tr>
        <td><?php echo $row['id'] ?></td>
        <td><?php echo $row['nom'] ?></td>
        <td><?php echo $row['client'] ?></td>
        <td><?php echo $row['dateresa'] ?></td>
        <td><?php echo $row['datesoiree'] ?></td>
        <td><?php echo $row['bouteille'] ?></td>
        <td><?php echo $row['bouteille2'] ?></td>
        <td><?php echo $row['places'] ?></td>
    </tr>
<?php endwhile ?>
</table>
 
 
 
        </font>
 
            </p>
 
 
 
 
 
 
 
 
        <p><font face="Verdana">
            <a href="../login/<?php echo $url_home; ?>"><font color="#FFFFFF">Retour à l'accueil</font></a><font color="#FFFFFF">
            </a></font></font><p>
 
            <p>
                    &nbsp;</div>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
</div><center>
&nbsp;</font></center>
 
</form>
 
 
</font>
 
 
<div align="center">
            <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
            <tr>
                <td id="ds_calclass"></td>
            </tr>
        </table>
        </tr>
    </table>
            </font>
</div>
 
 
<?php
//sessions 
    }
 
else
{
?>
<div class="message"><font color="#FFFFFF">Pour accéder à cette page, vous devez être connecté.</font><b><font color="#FFFFFF"><br />
    </font>
<a href="../login/connexion.php"><font color="#FFFFFF">Se connecter</font></a></b><p>&nbsp;</div>
<?php
}
?>
 
 
</body>
 
</html>

Voici le code de ma fonction OnChange JS

Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
function Lien() {
    i = document.Choix.Liste.selectedIndex;
    if (i == 0) return;
    url = document.Choix.Liste.options[i].value;
    parent.location.href = url;
}