par
Invité » 02 sept. 2007, 13:20
Bonjour,
Alors j'ai modifier le script comme suit:
Code : Tout sélectionner
<?php
header("Content-type: text/x-csv");
header("Content-disposition: attachment; filename=Historique_SNR_" . date("Ymd").".csv");
include("../include/connection.php");
//Lecture de la data base
$sql = ("
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(F0ROM_UNIXTIME(History.eventdate)),
MONTH(FROM_UNIXTIME(History.eventdate)),
Devices.name,
Interfaces.name,
Interfaces.description
;");
$resultat = mysql_query ($sql);
$list = "";
while ($snr = mysql_fetch_array ($resultat))
{
$month = $snr ['Month'];
$device = $snr ['DeviceName'];
$interface = $snr ['InterfaceName'];
$device2 = $snr ['InterfaceDesc'];
$minor = $snr ['Minor'];
$major = $snr ['Major'];
$critical = $snr ['Critical'];
$list .= "\"$month\",\"$device\",\"$interface\",\"$device2\",\"$minor\",\"$major\",\"$critical\"\r\n";
}
echo $list;
?>
Mais j'ai une erreur sur le while
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
vous auriez une idée ? parce que je sèche la
Bonjour,
Alors j'ai modifier le script comme suit:
[code]
<?php
header("Content-type: text/x-csv");
header("Content-disposition: attachment; filename=Historique_SNR_" . date("Ymd").".csv");
include("../include/connection.php");
//Lecture de la data base
$sql = ("
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(F0ROM_UNIXTIME(History.eventdate)),
MONTH(FROM_UNIXTIME(History.eventdate)),
Devices.name,
Interfaces.name,
Interfaces.description
;");
$resultat = mysql_query ($sql);
$list = "";
while ($snr = mysql_fetch_array ($resultat))
{
$month = $snr ['Month'];
$device = $snr ['DeviceName'];
$interface = $snr ['InterfaceName'];
$device2 = $snr ['InterfaceDesc'];
$minor = $snr ['Minor'];
$major = $snr ['Major'];
$critical = $snr ['Critical'];
$list .= "\"$month\",\"$device\",\"$interface\",\"$device2\",\"$minor\",\"$major\",\"$critical\"\r\n";
}
echo $list;
?>
[/code]
Mais j'ai une erreur sur le while
mysql_fetch_array(): supplied argument is not a valid MySQL result resource
vous auriez une idée ? parce que je sèche la