Probleme resultat requete

aureliemerlin Messages postés 82 Date d'inscription jeudi 24 juin 2010 Statut Membre Dernière intervention 17 avril 2013 - 4 févr. 2011 à 10:48
aureliemerlin Messages postés 82 Date d'inscription jeudi 24 juin 2010 Statut Membre Dernière intervention 17 avril 2013 - 4 févr. 2011 à 15:28
bonjour

J'ai un formulaire avec une zone de liste où je choisis un nom de client ensuite je clique sur une bouton rechercher pour afficher tous les clients par rapports à ma sélection
mais il m'affiche tout mes clients
je ne comprend pas pourquoi

voici les différents codes utilisés
1)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns= "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RECHERCHE CLIENT</title>
</head>

<?php
require_once('includes/templategc.php');
require_once('includes/magicquotes.inc.php');
require_once('includes/auxiliaires.inc.php');
require_once('includes/bd.inc.php');
$NomEmp = "";
$resultat = mysqli_query($lien, "Select Num, NomEmp, NomSoc, VilleEmp, TypeClient2, VilleSoc, CodeCom from bdclient group by NomEmp order by NomEmp");
if (!$resultat)
{
$erreur = 'Erreur de récupération de la liste des clients';
include 'erreur.html.php';
exit();
}
while ($ligne = mysqli_fetch_array($resultat))
{
$bdclient[] = array('Num' => $ligne['Num'], 'NomEmp' => $ligne['NomEmp'], 'NomSoc' => $ligne['NomSoc'], 'VilleEmp' => $ligne['VilleEmp'], 'TypeClient2' => $ligne['TypeClient2'], 'VilleSoc' => $ligne['VilleSoc'], 'CodeCom' => $ligne['CodeCom']);
}


include 'form_rechercheclient.html.php';
?>
<?php
if (isset($_GET['action']) and $_GET['action'] == 'rechercher')
{
require_once('includes/bd.inc.php');
$select = ' SELECT Num, NomEmp, CodeCom';
$from = ' FROM bdclient';
$where = ' WHERE TRUE';

$NomEmp = htmlspecialchars(mysqli_real_escape_string($lien, $_GET['NomEmp']));
if ($NomEmp != '')
{
$where .= " AND NomEmp='$NomEmp'";
}
$resultat = mysqli_query($lien, $select . $from . $where);
if (!$resultat)
{
$erreur = 'erreur dans la recherche du client';
include 'erreur.html.php';
exit();
}
while ($ligne = mysqli_fetch_array($resultat))
{
$bdclient[]= array('Num' => $ligne['Num'], 'NomEmp' => $ligne['NomEmp'], 'CodeCom' => $ligne['CodeCom']);
}
include 'client.html.php';
exit();
}

?>


<?php
pied();
?>


</html>
2) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RECHERCHE CLIENT</title>
</head>

<?php
require_once('includes/templategc.php');
require_once('includes/magicquotes.inc.php');
require_once('includes/auxiliaires.inc.php');
require_once('includes/bd.inc.php');
?>
gestion commerciale

[creaclientpart.php Nouveau client particulier]


<form action ="" method="get">
Voir les clients qui correspondent aux critéres suivants :




<label for="Num"></label>
<select name="NomEmp" id="NomEmp">
<option value=""<?php echo $NomEmp;?>"">Choisir un client</option>
<?php foreach ($bdclient as $client): ?>
<option value="<?php echo print_html($client['NomEmp']) ; ?>">
<?php echo print_html($client['NomEmp']) ; ?>
</option>
<?php endforeach; ?>

</select>








</form>


</html>
3)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RESULTAT RECHERCHE CLIENT</title>
</head>

<?php
require_once('includes/templategc.php');
require_once('includes/magicquotes.inc.php');
require_once('includes/auxiliaires.inc.php');
require_once('includes/bd.inc.php');
?>
<?php if (isset($bdclient)): ?>
client |Options |
<?php foreach ($bdclient as $client): ?>
----

<?php print_html($client['NomEmp']); ?>,
<form action ="?" method="post">

"/>
"/>
[? Nouvelle recherche]


[listeclients.php Retour au menu]



</html>

voila si quelqu'un à une idée

merci d'avance

Bonne journée

Aurélie

2 réponses

cod57 Messages postés 1653 Date d'inscription dimanche 7 septembre 2008 Statut Membre Dernière intervention 11 septembre 2013 19
4 févr. 2011 à 14:16
bonjour
<option value=""<?php echo $NomEmp;?>"">

plutôt

<option value="<?php echo $NomEmp;?>">

a++
0
aureliemerlin Messages postés 82 Date d'inscription jeudi 24 juin 2010 Statut Membre Dernière intervention 17 avril 2013
4 févr. 2011 à 15:28
ca ne marche pas non plus
0
Rejoignez-nous