Barre de recherche avec php

Résolu
lifa5 Messages postés 43 Date d'inscription vendredi 20 juin 2014 Statut Membre Dernière intervention 3 mai 2016 - Modifié par KX le 21/06/2014 à 11:53
lifa5 Messages postés 43 Date d'inscription vendredi 20 juin 2014 Statut Membre Dernière intervention 3 mai 2016 - 22 juin 2014 à 13:21
Bonjour, j'ai fait ce code et j'ai cet erreur

Notice: Undefined index: rechercherpar in C:\wamp\www\test1\banque\RechercherClient.php on line 54

Notice: Undefined index: mot_cle in C:\wamp\www\test1\banque\RechercherClient.php on line 55



Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\test1\banque\RechercherClient.php on line 65

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\test1\banque\RechercherClient.php on line 66





Code html

<form action="RechecherClient.php" method="Post">        
  Rechercher par <select name="rechercherpar">
                                  <option>id_client</option>
                                  <option>Nom_Client</option>
                                  <option>Prenom_Client</option>
                              </select>
          Mot clé <input type="text" name="mot_cle">
                     <input type="submit" value="Rechercher">





code


Code php

<?php
 
//Connexion Mysql
 require("Mysql_Connect.php");  
function search()
          {
   $champ=$_POST['rechercherpar'];
   $mot=$_POST['mot_cle'];
   
  $sql = "SELECT * FROM client
          WHERE  $champ=\"$mot\"";
// Affichage de la requête si besoin:
echo "<center><br><b></b></br></center>";

// Lancement de la requête :
$resultat=mysql_query($sql); 
   
$ligne=mysql_fetch_array($resultat);
$nb=mysql_num_rows($resultat);
$i=0;
       while($i<$nb)
          {
   $num=$ligne['id_client'];
   $type=$ligne['Nom_Client'];
   $soustype=$ligne['Prenom_Client'];
 echo $num.' '.$type.' '.$soustype;
$i=$i+1;
          }
          }
search();
?>


lifa8

7 réponses

Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 656
21 juin 2014 à 06:58
Bonjour, message modifié par l'ajout des balises de code.
Voir ici comment utiliser la coloration syntaxique.
0