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
|
?>
<form method="post" name="chgsite">
<fieldset>
<legend>Sélectionnez le client</legend>
<select name="client" id="catégorie" onchange="document.forms['chgsite'].submit();">
<option value="">- - - Choisissez une catégorie - - -</option>
<?php
$rech_client = $pdo->query('SELECT distinct nom_client FROM client ORDER BY nom_client');
if ($rech_client !== false) {
while ($data = $rech_client->fetch(PDO::FETCH_ASSOC)) {
echo '<option value="',$data['nom_client'],'"';
if(!empty($_POST['client']) && $_POST['client'] == $data['nom_client']){
echo ' selected="selected"';
}
echo '>',$data['nom_client'],'</option>';
}
$rech_client->closeCursor();
}
echo '</select><br />';
if (!empty($_POST['client'])){
/* Cération de la requête pour avoir les départements de cette région */
$stmt = $pdo->prepare('SELECT distinct site_client FROM client WHERE nom_client = :id ORDER BY site_client');
$stmt->bindParam(':id',$_POST['client']);
$stmt->execute();
echo '<select name="site" id="site">';
while($data = $stmt->fetch(PDO::FETCH_ASSOC)){
echo '<option value="',$data['site_client'],'"';
if(!empty($_POST['site']) && $_POST['site'] == $data['site_client']){
echo ' selected="selected"';
}
echo '>',$data['site_client'],'(',$data['site_client'],')</option>';
}
$stmt->closeCursor();
echo '</select>';
}
echo '<br>';
if (!empty($_POST['site'])){
/* Cération de la requête pour avoir les départements de cette région */
$stmtt = $pdo->prepare('SELECT salle_client FROM client WHERE site_client = :ie and nom_client=:ic');
$stmtt->bindParam(':ie',$_POST['site']);
$stmtt->bindParam(':ic',$_POST['client']);
$stmtt->execute();
echo '<select name="salle" id="salle">';
while($data = $stmtt->fetch(PDO::FETCH_ASSOC)){
echo '<option value="',$data['salle_client'],'"';
if(!empty($_POST['salle']) && $_POST['salle'] == $data['salle_client']){
echo ' selected="selected"';
}
echo '>',$data['salle_client'],'(',$data['salle_client'],')</option>';
}
$stmtt->closeCursor();
echo '</select>';
}
?>
<br />
<input type="submit" name="ok" id="ok" value="Envoyer" />
</fieldset>
</form> |
Partager