bonjour
j'ai fait un formulaire permettant une recherche a différents endroits de la base
avec une variable pour ce que l'on recherche et une pour l'endroit ou s'effectue la recherche, mais ce qui fonctionne bien quand j'écris
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
$mot=$_REQUEST['motclef'];
$searchpar=$_REQUEST['par'];
$recherche= '';
if (isset($mot)){
	$recherche= "WHERE  produits like '%$mot%'";
}
$sql= "SELECT * FROM produits ".$recherche;
$resultat=mysql_query($sql);
while ($produits =mysql_fetch_array ($resultat)){
ne fonctionne plus lorsque je mets
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
$mot=$_REQUEST['motclef'];
$searchpar=$_REQUEST['par'];
$recherche= '';
if (isset($mot)){
	$recherche= "WHERE  '%$searchpar%' like '%$mot%'";
}
$sql= "SELECT * FROM produits ".$recherche;
$resultat=mysql_query($sql);
while ($produits =mysql_fetch_array ($resultat)){
code avec le formulaire
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
<?php echo $_REQUEST['motclef'];?>
"/>
<input type="submit" value="rechercher"/>
 
  par
  <select name="par">
  <option value="id">utilisation
  <option value="reference"reference">nom</option>
  <option value="constructeur">constructeur</option>
  <option value="importateur">fournisseur
  </select>
  </form>
<br><br><br>
<table width=90% align=center border=1>
<tr>
<td class='photo' width="7%"><b>photo </td>
<td class='intitule'width="20%"><b>designation</td>
<td class= 'intitule'width="20%"><b>reference</td>
<td class='intitule'><b>distributeur</td>
<td class='pdf'><b>documentations</td></b>
<?php
 
$mot=$_REQUEST['motclef'];
$searchpar=$_REQUEST['par'];
$recherche= '';
if (isset($mot)){
	$recherche= "WHERE  '%$searchpar%' like '%$mot%'";
}
$sql= "SELECT * FROM produits ".$recherche;
$resultat=mysql_query($sql);
while ($produits =mysql_fetch_array ($resultat)){