Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 3.15.218.44
<?php
//ce fichier montre un exemple permettant de generer un fichier excel (on peut remplacer le .csv par .xls)
session_start();
//parametres de connexion a la bdd
include_once('../includes/mysql_connect.php');
//Premiere ligne = nom des champs (si on en a besoin)
$csv_output = "team_name,team_abbreviation";
$csv_output .= "\n";
//Requete SQL
$query = "SELECT team_name,team_abbreviation FROM lhjmqcsr_season_0708_pii.teams where saison_id = 1 ORDER BY team_name DESC";
$result = mysql_query($query, $mysql_link);
//$result = mysql_query($query) or die('Erreur SQL !<br />' . $query . '<br />' . mysql_error());
//Boucle sur les resultats
while($row = mysql_fetch_array($result)) {
$csv_output .= "$row[team_name] $row[team_abbreviation]\n";
}
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=AddressBook_" . date("Ymd").".xls");
print $csv_output;
exit;
?>
|