I am having yet another problem! My original is here Passing date between pages php and displaying year only
What I need to do now is enable that date to be used for the data which is exported to an excel doc. I have tried to add the normal parameters at the top but it just ignores them! This is the code I have at the top to create the excel doc. I hope someone can help.
$export_file = "ExcelFile.xls";
ob_end_clean();
ini_set('zlib.output_compression','Off');
header('Pragma: public');
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header ("Pragma: no-cache");
header("Expires: 0");
header('Content-Transfer-Encoding: none');
header('Content-Type: application/vnd.ms-excel;'); // This should work for IE & Opera
header("Content-type: application/x-msexcel"); // This should work for the rest
header('Content-Disposition: attachment; filename="'.basename($export_file).'"');
if(!($dbconnect = mysql_pconnect("localhost", "dbname", "pass"))){
print("Failed to connect to database!
");
exit();
}
$fromdatePost = $_POST["report_date_from"];
$todatePost = $_POST["report_date_to"];
$fromdate = $_POST["report_date_from"] .' 00:00:00';
$fromdate = preg_replace('#(\d{2})/(\d{2})/(\d{4})\s(.*)#', '$3-$2-$1 $4', $fromdate);
$todate = $_POST["report_date_to"] .' 00:00:00';
$todate = preg_replace('#(\d{2})/(\d{2})/(\d{4})\s(.*)#', '$3-$2-$1 $4', $todate);
$fromyear = date('Y', strtotime($fromdate));
$toyear = date('Y', strtotime($todate));