if (empty($data)) {
$data = "\n(0) Records Found!\n";}
header("Content-type: application/xmsdownload");
header("Content-Disposition: attachment; filename=".
$file_name.date("Y:m:d H:i").".xls");
header("Pragma: no-cache");
header("Expires; 0");
print "$header\n$data";
exit;
}else{
include "header.php";
include $template_path.$template;
include "footer.php";
}
Because the header.php is sent at the bottom of the page I can't have
the print to Excel output header in the if statement or I get the
message header already sent. I need the else statements where they
are because earlier in the code there are different selections of
templates depending on if a form is filled out so at the end it has to
display the right template.
Is there a way to send the excel output away from the page in a
function or something so that it processes the else?
thanks,
Nope. Once you've sent ANYTHING to the client, the web server sends
default headers.
You can send an Excel file or HTML in a request - but not both.
As has been explained to you time and time again...
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Okay, then maybe I can figure out how to redirect the excel if/excel
output to another page. the problem is then I have to requery the
database and run through all these queries depending on what a user
puts in a form. Is there a way to send the one query for the
selection to the redirected page so I don't have to go through all of
that?
thanks,
>Okay, then maybe I can figure out how to redirect the excel if/excel
>output to another page. the problem is then I have to requery the
>database and run through all these queries depending on what a user
>puts in a form. Is there a way to send the one query for the
>selection to the redirected page so I don't have to go through all of
>that?
>thanks,
The best way is to re-arrange your logic so that all processing is done
before any page output. This may involve temporarily storing the output
as variables. Once the logic is finished you can either redirect using
header() or echo the output variables.
Like Jerry says, you can't do both.
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk