1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| try {
$csv_output = "Type;N° inscrit;Nom;Prénom;Pôle;Métier;Divers;Inscrit le;Modifié le;Annulé le;Remplacé par;Hôtel;Catégorie;Type chambre;N° chambre fictif;N° chambre réel;Genre;19 mars;20 mars;21 mars;22 mars;23 mars;24 mars;Colocataire twin;Colocataire triple;Commentaires";
$csv_output .= "\n";
$req = $bdd->query('SELECT type, id, nom, prenom, pole, metier, divers, dateInscrit, dateModifie, dateAnnule, remplace, nomHotel, categorieHotel, typeChambre, numChambreFictif, numChambreReel, genre, CASE 19mars WHEN typeChambre ="SGL" THEN 1 WHEN typeChambre ="TWIN" THEN 0,5 ELSE 0 END, 20mars, 21mars, 22mars, 23mars, 24mars, colocataireTwin, colocataireTriple, commentaires FROM olympiades ORDER BY nom');
while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {
$csv_output .= implode(';',$donnees) . "\n";
}
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=Export_Global_" . date("Ymd").".csv");
print $csv_output;
exit;
} catch (PDOException e) {
echo 'Échec de la requête : ' . $e->getMessage();
exit;
} |
Partager