Tenebriox a écrit:
Essayes de faire un echo de ta requête pour voir si elle est correcte !
Merci. ça m'a mis sur la piste.
<?php
function search() {
$champ=$_POST['rechercherpar'];
$mot=$_POST['mot_cle'];
$resultat = mysql_query("select * from produits where $champ= '".$mot."'");
$ligne = mysql_fetch_array($resultat);
$nb = mysql_num_rows($resultat);
$i=0;
while($i<$nb) {
$nom=$ligne['nocat'];
$prenom=$ligne['details'];
$tel=$ligne['prix'];
echo $nom.' '.$prenom.' '.$tel.'<br />';
$i=$i+1;
}
}
search();
?>
<form action="" method="post">
Rechercher par <select name="rechercherpar">
<option value="nocat">nocat</option>
<option value="details">details</option>
</select>
Mot clé <input type="text" name="mot_cle">
<input type="submit" value="Rechercher">
</form>
search();
Ça marche bien. Il faut que je l'adapte à mon script principal.