Bonjour à tous, je vous exprime mon soucis, cela fait pas mal de temps que je m'y penche sans jamais arriver trouver vraiment la solution.

Je vous explique un peu, sur mon site apparaît des petites annonces, et comme j'en ai de plus en plus, je voulais faire un tri par département.

Seulement voila, en utilisant une listbox, je suis arriver au résultat suivant, soit j'arrive sur la page et je dois choisir un département pour afficher quelque chose, soit j'arrive sur la page et tout s'affiche mais je ne peux pas trier par département

J'apprends le php au fur et à mesure donc soyez clément sur ma façon de coder.
Je vous poste mon code actuel.

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
106
107
108
 
<table width="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
  <tr>
    <td><table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFE9B5">
      <tr>
        <td width="100">Choix par dept </td>
        <td><form name="indicateur" action="test.php" method="post">
          <div align="center">
            <select name="lieu">
              <option value="%" selected="selected">Tout</option>
              <option value="01">01</option>
              <option value="02">02</option>
              <option value="03">03</option>
              <option value="04">04</option>
              <option value="05">05</option>
              <option value="06">06</option>
              <option value="07">07</option>
              <option value="08">08</option>
              <option value="09">09</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              </select>
            <input name="submit" type="submit" value="soumettre">
          </div>
        </form></td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<br>
 
 
<table cellspacing=0 cellpadding=0 width=500 border=0>
  <tbody>
    <tr>
      <td colspan=3 height=17><p class=bold><img src="../title/t_petites-annonces.gif" width="511" height="17"></p></td>
    </tr>
    <tr>
      <td colspan=3><img src="../cadre/bloc-haut.gif" width="511" height="34"></td>
    </tr>
    <tr>
      <td background=../commun/pix-noir.gif 
            height="100%"><img height="100%" 
            src="../commun/pix-noir.gif" width=1></td>
      <td width=492 bgcolor=#ffe9b5 class="bold"><a href="index-annonce.php"><br>
            <img src="../menu-agenda/photo/puce-o.gif" width="9" height="9" border="0"> Poster une annonce</a><br>
            <br>
            <table border=0 cellspacing="0" cellpadding="3" width="100%">
              <tr>
                <td><div class=bold> Date</div></td>
                <td><div class=bold>Titre</div></td>
                <td><div class=bold>Dept.</div></td>
              </tr>
              <?php
// connexion a la base
require_once("admin/connexion.php");
 
$BD_link = mysql_connect("${'BD_host'}${'BD_port'}", $BD_login, $BD_pass) or die("Connexion de la base impossible : ". mysql_error());
 
//selection de la table
 
 
mysql_select_db($BD_base, $BD_link) or die("S&eacute;lection de la base impossible : ". mysql_error());
$Requete_SQL2 = "SELECT * FROM test WHERE valid = '1' AND lieu LIKE '$lieu' ORDER BY date DESC ";
 
$result = mysql_query($Requete_SQL2) or die("Erreur de S&eacute;lection dans la base : ". $Requete_SQL2 .'<br />'. mysql_error());
 
// creation et affichage dans la table
error_reporting(55); 
 
 
while($val=mysql_fetch_array($result))
if($val["valid"] == 1)
{
$id=$val[ID];
$num=$val[date];
$nom=$val[titre];
$pre=$val[lieu];
 
 
echo"<tr>";
echo"<td width=84 align=left>";
echo"<DIV class=bold>";
echo"$num";
echo"</DIV>";
echo"</td>";
echo"<td align=left>";
echo"<SPAN class=normal>";
echo"<a href=\"test.php?id=",$id,"\">",$nom,"</a>";
echo"</SPAN>";
echo"</td>";
echo"<td width=20 align=left>";
echo"<DIV class=bold>";
echo"$pre";
echo"</DIV>";
echo"</td>";
echo"</tr>";
}
 
mysql_close();
?>
            </table>