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
| <?php
// on crée la requête SQL
$sql = 'SELECT cdc,com FROM com WHERE cdw =:cdw ORDER BY cdc DESC';
$sqlcom=$cbd->prepare($sql);
$sqlcom->bindParam(':cdw', $_SESSION['cdw'], PDO::PARAM_INT);
$sqlcom->execute();
// On récupère en 1er toutes les données
$datacom = $sqlcom->fetchAll(PDO::FETCH_ASSOC);
// Partie interface
?>
<html>
... etc ...
<body>
... etc ...
<select name="choix_com">
<?php
foreach ($datacom as $com) {
// on affiche les informations de l'enregistrement en cours
echo '<option value="'.$com['cdc'].'">'.$com['com'].'</option>';
}
?>
</select>
</body>
</html> |
Partager