Voici mon code:
Code : Tout sélectionner
function getSouscategories(){
global $bdd;
$sql="SELECT C.id ,
case $_SESSION['lang']
when 'FR' then C.nom_FR
when 'EN' then C.nom_EN
when 'ES' then C.nom_ES
end as C.nom
, case $_SESSION['lang']
when 'FR' then DESC_C.nom_FR
when 'EN' then DESC_C.nom_EN
when 'ES' then DESC_C.nom_ES
end as DESC_C.nom
FROM categories C ";
try{
$req = $bdd->prepare($sql);
$req->execute();
$res = $req->fetchAll(PDO::FETCH_ASSOC);
}catch(Exception $e){
echo "Erreur dans la requête " . $sql;
$res = false;
}
return $res;
}
Code : Tout sélectionner
$categories=getSouscategories();
<select name="categorie">
<?php
foreach($categories as $C){
echo "<option value='".$C['id']."'>".$C['nom']."</option>";
}
?>
</select>