IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Ajouter un critère de recherche [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 62
    Par défaut Ajouter un critère de recherche
    Bonjour, j'ai un formulaire de recherche pour une liste de biens immobiliers.

    Le champ code postal(biensecteur) permet de faire une recherche sur 5 chiffres, j'aimerai mettre une requête mysqul pour que la recherche puisse se faire ausi sur 2 secterus (é et 5 chiffres donc).

    Merci d'avance

    Cdt :

    voici la source
    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
    109
     
    <script language="javascript">
    function srch(){
     document.regform.search.value=1;
     document.regform.submit();
    }
     
    function init(){
     document.regform.bienville.value="";
     document.regform.biensecteur.value="";
     document.regform.biensurfacemini.value="";
     document.regform.biensurfacemaxi.value="";
     document.regform.tybiref.value=0;
     document.regform.submit();
    }
    </script>
    </head>
    <body>
    <form target="_top" method="post" name="regform"  action="plan_secteurs.php">
      <p>
      <input type="hidden" name="search" value="">   
      </p>
    <div align="left">
        <div align="left">
          <div align="left">
            <table width="13%" border="0" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#666666" style="border-collapse: collapse">
              <tr bgcolor="#FFFFFF">
                <td height="27" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style29"><font face='Arial'><font face='Arial'>RECHERCHE RAPIDE</font></font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td width="152" height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style37"><font face='Arial'><font face='Arial'>TYPE</font></font></span></td>
              </tr>
              <tr>
                <td height="30" align="left" valign="middle" background="#FFFFFF" bgcolor="#666666" class="Style14" ><select class="i1" name="tybiref">
                  <option value="0"><?php echo $lg[1]; ?></option>
                  <?php
    $order="1";
    if($lang=="en"){ $order="2"; }
    if($lang=="it"){ $order="3"; }
    if($lang=="de"){ $order="4"; }
    if($lang=="su"){ $order="5"; }
    if($lang=="fi"){ $order="6"; }
    $SQL="SELECT * FROM types_de_biens WHERE tybisuppr=0 ORDER BY tybinom".$order;
    $affichage=mysql_query($SQL);
    $nb=mysql_numrows($affichage);
    if($nb){
     while($ligne=mysql_fetch_array($affichage)){
      $tybiref2=stripslashes($ligne["tybiref"]);
      $tybinom=stripslashes($ligne["tybinom1"]);
      $tybinom2=stripslashes($ligne["tybinom2"]);
      $tybinom3=stripslashes($ligne["tybinom3"]);
      $tybinom4=stripslashes($ligne["tybinom4"]);
      $tybinom5=stripslashes($ligne["tybinom5"]);
      $tybinom6=stripslashes($ligne["tybinom6"]);
      if($lang=="en"){ $tybinom=$tybinom2; }
      if($lang=="it"){ $tybinom=$tybinom3; }
      if($lang=="de"){ $tybinom=$tybinom4; }
      if($lang=="su"){ $tybinom=$tybinom5; }
      if($lang=="fi"){ $tybinom=$tybinom6; }
      echo "<option value=\"".$tybiref2."\"";
      if($tybiref==$tybiref2){ echo " selected"; }
      echo ">".$tybinom."</option>";
     }
    }
    ?>
                </select></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>VILLE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><input name="bienville" type="text" class="Style14" size="20" maxlength="35" value="<?php echo $bienville; ?>"></td>
              </tr>
              <tr bgcolor="#FFFFFF">
     <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>CODE POSTAL </font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" > <input name="biensecteur" type="text" class="Style14" size="5" maxlength="5" value="<?php echo $biensecteur; ?>"></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>SURFACE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><table width="96" border="0">
                    <tr>
                      <td width="25" height="30" align="right" valign="middle" background="#FFFFFF" ><p class="Style36 Style41">ENTRE</p>                  </td>
                      <td width="22" align="left" valign="middle" background="#FFFFFF" ><div align="left">
                        <input name="biensurfacemini" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemini; ?>">
                      </div></td>
                      <td width="18" align="right" valign="middle" background="#FFFFFF" ><div align="center"><span class="Style36 Style41">ET</span></div></td>
                      <td width="24" align="left" valign="middle" background="#999999" bgcolor="#666666" ><div align="left">
                        <input name="biensurfacemaxi" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemaxi; ?>">
                      </div></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td bgcolor="#666666" height="20" align="center" class="Style14"><p class="Style23">
                   <input name="Submit" type="button" class="standard" onClick="srch();" value="<?php echo $lg[56]; ?>">
                </p></td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </form>
    </body>
    </html>
    <?php include_once("req_deconnecter.php"); ?>

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    la recherche puisse se faire ausi sur 2 secterus (é et 5 chiffres donc).
    tu veux dire pouvoir rechercher sur 2 codes postaux au lieu d'un actuellement ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre émérite
    Avatar de amoiraud
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2006
    Messages
    606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2006
    Messages : 606
    Par défaut
    J'ai pas vraiment compris mais essaye ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    //1 secteur :
    $requete = mysql_query('SELECT * FROM types_de_biens WHERE biensecteur = "'.$_POST['biensecteur'].'" ORDER BY tybinom');
     
    //2secteurs :
    $requete2 = mysql_query('SELECT * FROM types_de_biens WHERE biensecteur = "'.$_POST['biensecteur2'].'" OR biensecteur = "'.$_POST['biensecteur2'].'" ORDER BY tybinom');

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 62
    Par défaut
    Merci p$our vos réponses actuellement le champ secteur est composé de 5 chiffres (code postal), j'aimerai que l'on puisse aussi taper que les 2 premiers pour que dans le futur cela engendre les départements ? La requete dans le champ secteur pourra etre de 2 ou 5 chiffres

    Merci d'avance

    Cdt

  5. #5
    Membre émérite Avatar de obito
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2008
    Messages
    773
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Janvier 2008
    Messages : 773
    Par défaut
    Bonjour ! peut être une requete de ce genre pourrait t'aider?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $req=mysql_query("SELECT champ FROM table WHERE cp LIKE '".$_POST['codepostal']."%'");
    A adapter bien sur

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 62
    Par défaut
    Merci beacoup mais je la met où cette requête en dessous de cela :

    <input name="biensecteur" type="text" class="Style14" size="5" maxlength="5" value="<?php echo $biensecteur; ?>">

    Merci d'avance

  7. #7
    Membre émérite Avatar de obito
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2008
    Messages
    773
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Janvier 2008
    Messages : 773
    Par défaut
    Ben je pensais qu'il faudrait la placer après le formulaire lorsque l'on teste si les champs ne sont pas vides, ect...

    Ainsi l'utilisateur saisi par exemple 33 et après clique sur le bouton "valider" (par exemple), cela lui affiche tout les secteurs commençant par 33, à moins que ce ne soit pas ce que tu souhaite faire?^^

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 62
    Par défaut
    <input name="biensecteur" type="text" class="Style14" size="5" maxlength="5" value="<?php echo $biensecteur; $requete=mysql_query("SELECT * FROM biens WHERE biensecteur LIKE '".$_POST['biensecteur']."%'"); ?>" ></td>

    Je ne connaît pas du tout ce language, j'ai mis le bon nom de table : biens

    le champ concerné c biensecteur et cela ne marche toujours pas c'est peut être * à la place de champ ?????

    Merci beaucoup de votre aide je ne pipe rien

  9. #9
    Membre émérite
    Avatar de amoiraud
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2006
    Messages
    606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2006
    Messages : 606
    Par défaut
    Tu ne peut pas mettre la requête dans l'input, pour traiter le formulaire il faut le valider, il faut donc que tu mette dans ton formulaire un bouton submit (<input type="submit" value="Envoyer" />), tu envoi le formulaire sur une page de traitement ou sur la meme page que le formulaire y'a pas d'importance et après tu met ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    if(isset($_POST['biensecteur']) && $_POST['biensecteur'] != ""){
      $biensecteur = $_POST['biensecteur'];
      if(strlen($biensecteur) == 5){
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur = '".$biensecteur."'");
      }else{
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur LIKE '%".$biensecteur."%'");
      }
    }

  10. #10
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2009
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2009
    Messages : 62
    Par défaut
    Merci beaucoup pour ta réponse et en là mettant là après le form c bon ?

    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
    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
    <?php
    include_once("req_connecter.php");
     
    session_start();
    if($lng==""){
     $lang=$lng;
     $_SESSION["lang"]=$lang;
    }else{
     $lang=$_SESSION["lang"];
    }
     
    include_once("langue.php");
     
    if($search==1){ include_once("biens_liste2.php"); exit(); }
     
    ?>
    <html>
    <head>
    <title>Rechercher</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {	background-color: #666666;}
    body,td,th {	font-family: Arial,;	font-size: 12px;	color: #ffffff;	font-style: normal;	line-height: normal;	font-weight: 100;}
    a {	font-size: 24px;	color: #FAC634;	font-weight: bold;}
    a:visited {	color: #000000;	text-decoration: none;}
    a:hover {	color: #645D90;	text-decoration: none;}
    a:active {	color: #645D90;	text-decoration: none;}
    a:link {	text-decoration: none;	color: #990000;}
     
    a.standard {	font-family: Arial;  font-size: 16px;	color: #333333;}
    a.standard:link {	text-decoration: none;	color: #333333;}
    a.standard:visited {	text-decoration: none;	color: #333333;}
    a.standard:hover {	text-decoration: none;	color: #990000;}
    a.standard:active {	text-decoration: none;	color: #333333;}
    .Style14 {color: #000000}
    .Style24rouge {	font-size: 24px;	font-weight: bold;	font-family: Arial, Helvetica, sans-serif;	color: #000000;	font-style: normal;	line-height: normal;	font-variant: normal;}
    h1,h2,h3,h4,h5,h6 {	font-family: Arial, Helvetica, sans-serif;	font-weight: bold;}
    h2 {	font-size: 12px;	color: #000000;}
     
    INPUT.i1, TEXTAREA.i1, SUBMIT.i1, SELECT.i1, OPTION.i1, BUTTON.i1 {
     border-style: solid; border-width: 1px; border-color:#999999; background-color: #FFFFFF; font-size: 9pt; font-family:  arial, helvetica, sans serif;
    }
     
    table.t1, table.t3 { border-spacing: 0; }
     
    td.t1 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
    td.t2 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
     
    td.t3 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
    .Style23 {color: #666666}
    .Style29 {	color: #36A828;
    	font-size: 15px;
    	font-weight: bold;
    }
    .Style36 {font-size: 9px}
    .Style37 {
    	color: #FFFFFF;
    	font-weight: bold;
    }
    .Style40 {font-size: 12px; font-weight: bold; color: #FFFFFF; }
    .Style41 {color: #FFFFFF}
     
    -->
    </style>
    <script language="javascript">
    function srch(){
     document.regform.search.value=1;
     document.regform.submit();
    }
     
    function init(){
     document.regform.bienville.value="";
     document.regform.biensecteur.value="";
     document.regform.biensurfacemini.value="";
     document.regform.biensurfacemaxi.value="";
     document.regform.tybiref.value=0;
     document.regform.submit();
    }
    </script>
    </head>
    <body>
    <form target="_top" method="post" name="regform"  action="plan_secteurs.php">
      <p>
      <input type="hidden" name="search" value="">   
      </p>
    <div align="left">
        <div align="left">
          <div align="left">
            <table width="13%" border="0" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#666666" style="border-collapse: collapse">
              <tr bgcolor="#FFFFFF">
                <td height="27" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style29"><font face='Arial'><font face='Arial'>RECHERCHE RAPIDE</font></font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td width="152" height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style37"><font face='Arial'><font face='Arial'>TYPE</font></font></span></td>
              </tr>
              <tr>
                <td height="30" align="left" valign="middle" background="#FFFFFF" bgcolor="#666666" class="Style14" ><select class="i1" name="tybiref">
                  <option value="0"><?php echo $lg[1]; ?></option>
                  <?php
    $order="1";
    if($lang=="en"){ $order="2"; }
    if($lang=="it"){ $order="3"; }
    if($lang=="de"){ $order="4"; }
    if($lang=="su"){ $order="5"; }
    if($lang=="fi"){ $order="6"; }
    $SQL="SELECT * FROM types_de_biens WHERE tybisuppr=0 ORDER BY tybinom".$order;
    $affichage=mysql_query($SQL);
    $nb=mysql_numrows($affichage);
    if($nb){
     while($ligne=mysql_fetch_array($affichage)){
      $tybiref2=stripslashes($ligne["tybiref"]);
      $tybinom=stripslashes($ligne["tybinom1"]);
      $tybinom2=stripslashes($ligne["tybinom2"]);
      $tybinom3=stripslashes($ligne["tybinom3"]);
      $tybinom4=stripslashes($ligne["tybinom4"]);
      $tybinom5=stripslashes($ligne["tybinom5"]);
      $tybinom6=stripslashes($ligne["tybinom6"]);
      if($lang=="en"){ $tybinom=$tybinom2; }
      if($lang=="it"){ $tybinom=$tybinom3; }
      if($lang=="de"){ $tybinom=$tybinom4; }
      if($lang=="su"){ $tybinom=$tybinom5; }
      if($lang=="fi"){ $tybinom=$tybinom6; }
      echo "<option value=\"".$tybiref2."\"";
      if($tybiref==$tybiref2){ echo " selected"; }
      echo ">".$tybinom."</option>";
     }
    }
     
     
    ?>
                </select></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>VILLE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><input name="bienville" type="text" class="Style14" size="20" maxlength="35" value="<?php echo $bienville; ?>"></td>
              </tr>
              <tr bgcolor="#FFFFFF">
     <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>CODE POSTAL </font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" > <input name="biensecteur" type="text" class="Style14" size="5" maxlength="5" value="<?php echo $biensecteur;  ?>" >
     
    			</td>
     
     
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>SURFACE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><table width="96" border="0">
                    <tr>
                      <td width="25" height="30" align="right" valign="middle" background="#FFFFFF" ><p class="Style36 Style41">ENTRE</p>                  </td>
                      <td width="22" align="left" valign="middle" background="#FFFFFF" ><div align="left">
                        <input name="biensurfacemini" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemini;  ?>">
                      </div></td>
                      <td width="18" align="right" valign="middle" background="#FFFFFF" ><div align="center"><span class="Style36 Style41">ET</span></div></td>
                      <td width="24" align="left" valign="middle" background="#999999" bgcolor="#666666" ><div align="left">
                        <input name="biensurfacemaxi" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemaxi; ?>">
                      </div></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td bgcolor="#666666" height="20" align="center" class="Style14"><p class="Style23">
     
     
                   <input name="Submit" type="button" class="standard" onClick="srch();" value="<?php echo $lg[56];  ?>">
     
     
                </p></td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </form>
    <?php if(isset($_POST['biensecteur']) && $_POST['biensecteur'] != ""){
      $biensecteur = $_POST['biensecteur'];
      if(strlen($biensecteur) == 5){
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur = '".$biensecteur."'");
      }else{
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur LIKE '%".$biensecteur."%'");
      }
    }?>
    </body>
    </html>
     
    <?php include_once("req_deconnecter.php"); ?>

  11. #11
    Membre émérite
    Avatar de amoiraud
    Homme Profil pro
    Développeur Web
    Inscrit en
    Octobre 2006
    Messages
    606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2006
    Messages : 606
    Par défaut
    Citation Envoyé par brunochp Voir le message
    Merci beaucoup pour ta réponse et en là mettant là après le form c bon ?

    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
    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
    <?php
    include_once("req_connecter.php");
     
    session_start();
    if($lng==""){
     $lang=$lng;
     $_SESSION["lang"]=$lang;
    }else{
     $lang=$_SESSION["lang"];
    }
     
    include_once("langue.php");
     
    if($search==1){ include_once("biens_liste2.php"); exit(); }
     
    ?>
    <html>
    <head>
    <title>Rechercher</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    body {	background-color: #666666;}
    body,td,th {	font-family: Arial,;	font-size: 12px;	color: #ffffff;	font-style: normal;	line-height: normal;	font-weight: 100;}
    a {	font-size: 24px;	color: #FAC634;	font-weight: bold;}
    a:visited {	color: #000000;	text-decoration: none;}
    a:hover {	color: #645D90;	text-decoration: none;}
    a:active {	color: #645D90;	text-decoration: none;}
    a:link {	text-decoration: none;	color: #990000;}
     
    a.standard {	font-family: Arial;  font-size: 16px;	color: #333333;}
    a.standard:link {	text-decoration: none;	color: #333333;}
    a.standard:visited {	text-decoration: none;	color: #333333;}
    a.standard:hover {	text-decoration: none;	color: #990000;}
    a.standard:active {	text-decoration: none;	color: #333333;}
    .Style14 {color: #000000}
    .Style24rouge {	font-size: 24px;	font-weight: bold;	font-family: Arial, Helvetica, sans-serif;	color: #000000;	font-style: normal;	line-height: normal;	font-variant: normal;}
    h1,h2,h3,h4,h5,h6 {	font-family: Arial, Helvetica, sans-serif;	font-weight: bold;}
    h2 {	font-size: 12px;	color: #000000;}
     
    INPUT.i1, TEXTAREA.i1, SUBMIT.i1, SELECT.i1, OPTION.i1, BUTTON.i1 {
     border-style: solid; border-width: 1px; border-color:#999999; background-color: #FFFFFF; font-size: 9pt; font-family:  arial, helvetica, sans serif;
    }
     
    table.t1, table.t3 { border-spacing: 0; }
     
    td.t1 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
    td.t2 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
     
    td.t3 {    border-color: #000000;
        border-style: solid;
        margin: 0px;
        padding: 0px;
        border-width: 0px 0px 0px 0px;
    }
    .Style23 {color: #666666}
    .Style29 {	color: #36A828;
    	font-size: 15px;
    	font-weight: bold;
    }
    .Style36 {font-size: 9px}
    .Style37 {
    	color: #FFFFFF;
    	font-weight: bold;
    }
    .Style40 {font-size: 12px; font-weight: bold; color: #FFFFFF; }
    .Style41 {color: #FFFFFF}
     
    -->
    </style>
    <script language="javascript">
    function srch(){
     document.regform.search.value=1;
     document.regform.submit();
    }
     
    function init(){
     document.regform.bienville.value="";
     document.regform.biensecteur.value="";
     document.regform.biensurfacemini.value="";
     document.regform.biensurfacemaxi.value="";
     document.regform.tybiref.value=0;
     document.regform.submit();
    }
    </script>
    </head>
    <body>
    <form target="_top" method="post" name="regform"  action="plan_secteurs.php">
      <p>
      <input type="hidden" name="search" value="">   
      </p>
    <div align="left">
        <div align="left">
          <div align="left">
            <table width="13%" border="0" cellpadding="5" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#666666" style="border-collapse: collapse">
              <tr bgcolor="#FFFFFF">
                <td height="27" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style29"><font face='Arial'><font face='Arial'>RECHERCHE RAPIDE</font></font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td width="152" height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style37"><font face='Arial'><font face='Arial'>TYPE</font></font></span></td>
              </tr>
              <tr>
                <td height="30" align="left" valign="middle" background="#FFFFFF" bgcolor="#666666" class="Style14" ><select class="i1" name="tybiref">
                  <option value="0"><?php echo $lg[1]; ?></option>
                  <?php
    $order="1";
    if($lang=="en"){ $order="2"; }
    if($lang=="it"){ $order="3"; }
    if($lang=="de"){ $order="4"; }
    if($lang=="su"){ $order="5"; }
    if($lang=="fi"){ $order="6"; }
    $SQL="SELECT * FROM types_de_biens WHERE tybisuppr=0 ORDER BY tybinom".$order;
    $affichage=mysql_query($SQL);
    $nb=mysql_numrows($affichage);
    if($nb){
     while($ligne=mysql_fetch_array($affichage)){
      $tybiref2=stripslashes($ligne["tybiref"]);
      $tybinom=stripslashes($ligne["tybinom1"]);
      $tybinom2=stripslashes($ligne["tybinom2"]);
      $tybinom3=stripslashes($ligne["tybinom3"]);
      $tybinom4=stripslashes($ligne["tybinom4"]);
      $tybinom5=stripslashes($ligne["tybinom5"]);
      $tybinom6=stripslashes($ligne["tybinom6"]);
      if($lang=="en"){ $tybinom=$tybinom2; }
      if($lang=="it"){ $tybinom=$tybinom3; }
      if($lang=="de"){ $tybinom=$tybinom4; }
      if($lang=="su"){ $tybinom=$tybinom5; }
      if($lang=="fi"){ $tybinom=$tybinom6; }
      echo "<option value=\"".$tybiref2."\"";
      if($tybiref==$tybiref2){ echo " selected"; }
      echo ">".$tybinom."</option>";
     }
    }
     
     
    ?>
                </select></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>VILLE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><input name="bienville" type="text" class="Style14" size="20" maxlength="35" value="<?php echo $bienville; ?>"></td>
              </tr>
              <tr bgcolor="#FFFFFF">
     <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>CODE POSTAL </font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" > <input name="biensecteur" type="text" class="Style14" size="5" maxlength="5" value="<?php echo $biensecteur;  ?>" >
     
    			</td>
     
     
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="25" bordercolor="#FFFFFF" bgcolor="#666666" ><span class="Style40"><font face='Arial'>SURFACE</font></span></td>
              </tr>
              <tr bgcolor="#FFFFFF">
                <td height="17" bordercolor="#FFFFFF" bgcolor="#666666" ><table width="96" border="0">
                    <tr>
                      <td width="25" height="30" align="right" valign="middle" background="#FFFFFF" ><p class="Style36 Style41">ENTRE</p>                  </td>
                      <td width="22" align="left" valign="middle" background="#FFFFFF" ><div align="left">
                        <input name="biensurfacemini" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemini;  ?>">
                      </div></td>
                      <td width="18" align="right" valign="middle" background="#FFFFFF" ><div align="center"><span class="Style36 Style41">ET</span></div></td>
                      <td width="24" align="left" valign="middle" background="#999999" bgcolor="#666666" ><div align="left">
                        <input name="biensurfacemaxi" type="text" class="i1" size="4" maxlength="6" value="<?php echo $biensurfacemaxi; ?>">
                      </div></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td bgcolor="#666666" height="20" align="center" class="Style14"><p class="Style23">
     
     
                   <input name="Submit" type="button" class="standard" onClick="srch();" value="<?php echo $lg[56];  ?>">
     
     
                </p></td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </form>
    <?php if(isset($_POST['biensecteur']) && $_POST['biensecteur'] != ""){
      $biensecteur = $_POST['biensecteur'];
      if(strlen($biensecteur) == 5){
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur = '".$biensecteur."'");
      }else{
        $requete=mysql_query("SELECT * FROM biens WHERE biensecteur LIKE '%".$biensecteur."%'");
      }
    }?>
    </body>
    </html>
     
    <?php include_once("req_deconnecter.php"); ?>
    Oui comme ca c'est bon, par contre ton submit doit etre de type submit et le form tu doit rajouter action="page.php"

    Ensuite pour afficher les résultat de la requête utilise la fonction mysql_fetch_array()

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 28
    Dernier message: 28/03/2012, 15h42
  2. [Joomla!] Ajouter un critère de recherche
    Par brunochp dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 1
    Dernier message: 11/03/2009, 10h17
  3. Requête avec comme critère de recherche un %
    Par Poussy-Puce dans le forum Langage SQL
    Réponses: 1
    Dernier message: 23/03/2006, 21h15
  4. Réponses: 3
    Dernier message: 27/10/2005, 08h39
  5. Ajout de critères dans Select utilisé par xp_sendmail
    Par bd0606 dans le forum MS SQL Server
    Réponses: 8
    Dernier message: 28/05/2004, 18h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo