Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi!
Has anyone ever used the MS-Excel Stream Handler Class? It is located here: http://www.phpclasses.org/browse/package/1919.html . Anyhow, my problem is that when I open export.php, nothing opens except a blank HTML page, where an XLS with all my data is supposed to pop-up.
Here is my export.php. I only changed a few things to get my data:Code: Select all
<?php
session_start();
if($_SESSION["online"] != "granted")
{
echo '<script>alert("Your account is not authorized to access this area.");</script>';
echo '<META http-equiv="refresh" content="0;URL=index.html" target="_top">';
exit;
}
$view_id = "$_SESSION[aircraft_id]";
require_once "excel.php";
$export_file = "xlsfile://tmp/example.xls";
$fp = fopen($export_file, "wb");
if (!is_resource($fp))
{
die("Cannot open $export_file");
}
// typically this will be generated/read from a database table
if(isset($w) && ($w==1))
{
include("connect.php");
$sql = "SELECT dwntime_type, dwntime_ata, dwntime_year, dwntime_month, dwntime_day, dwntime_start, dwntime_end, dwntime_hrs, dwntime_reason, dwntime_solution, dwntime_log, dwntime_log_by FROM downtime WHERE aircraft_id='$view_id' AND dwntime_year='$year' AND dwntime_month='$month'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$dwntime_type = ucfirst(stripslashes($row['dwntime_type']));
$dwntime_hrs = round($row['dwntime_hrs'], 2);
$dwntime_s = $row['dwntime_start'];
$dwntime_e = $row['dwntime_end'];
$dwntime_ata = $row['dwntime_ata'];
$dwntime_reason = stripslashes($row['dwntime_reason']);
$dwntime_solution = stripslashes($row['dwntime_solution']);
$dwntime_log = $row['dwntime_log'];
$dwntime_log_by = stripslashes($row['dwntime_log_by']);
$dwntime_day = $row['dwntime_day'];
$dwntime_month = $row['dwntime_month'];
$dwntime_year = $row['dwntime_year'];
$dwntime_times = "$dwntime_s - $dwntime_e";
$string = "$dwntime_year - $dwntime_month - $dwntime_day";
$dwntime_date = str_replace(' ', '', $string);
$assoc .= array(array("Type" => "$dwntime_type", "Date" => "$dwntime_date", "Downtime" => "$dwntime_times", "Hours Down" => "$dwntime_hrs", "ATA" => "$dwntime_ata", "Discrepancy" => "$dwntime_reason", "Resolution" => "$dwntime_solution", "Logged" => "$dwntime_log", "Logged By" => "$dwntime_log_by",),);
}
fwrite($fp, serialize($assoc));
fclose($fp);
}
?>Thanks very much,
- Jeff
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]