Voila je travail sur un petit script qui doit sortir un fichier csv tout fonctionne ou presque les données ne sont pas incluse dans le fichier csv je pense qu'il doit y avoir une erreur mais je n'arrive pas a trouver laquel.
Voici mon Code:
Code : Tout sélectionner
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=Historique_SNR_" . date("Ymd").".csv");
$csv_output = 'Month;DeviceName;InterfaceName;InterfaceDesc;Minor;Major;Critical';
//$csv_output .= "\n";
include("../include/connection.php");
//Lecture de la data base
$query = ("
select
YEAR(FROM_UNIXTIME(History.eventdate)) as Year,
MONTH(FROM_UNIXTIME(History.eventdate)) as Month,
Devices.name as DeviceName,
Interfaces.name as InterfaceName,
Devices.name2 as devicesName2,
Interfaces.description as InterfaceDesc,
SUM(case StatusTypes.name when 'Normal' then 1 else 0 end) as Normal,
SUM(case StatusTypes.name when 'Minor' then 1 else 0 end) as Minor,
SUM(case StatusTypes.name when 'Major' then 1 else 0 end) as Major,
SUM(case StatusTypes.name when 'Critical' then 1 else 0 end) as Critical
from
History
inner join StatusTypes on History.statusid = StatusTypes.id
inner join Cells on History.cellid = Cells.id
inner join Interfaces on Cells.interfaceid = Interfaces.id
inner join ServiceTypes on Cells.serviceid = ServiceTypes.id
inner join Devices on Interfaces.deviceid = Devices.id
where
ServiceTypes.name = 'SNR'
group by
YEAR(FROM_UNIXTIME(History.eventdate)),
MONTH(FROM_UNIXTIME(History.eventdate)),
Devices.name,
Interfaces.name,
Interfaces.description
;");
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$cvs_output = "$result[Month],$result[DeviceName],$result[InterfaceName],$result[devicesName2],$result[InterfaceDesc],$result[Ninor],$result[Major],$result[Critical]\n";
}
print $csv_output;
exit;
?>