I have a function to save table data (read from oracle) to a csv file.
The function works fine.
The problem occurs when I add "header" to the function.
If i use header to prompt the user to save the file, the entire page is saved to the file not just what I output to the file.
I cannot put the code here...as it is on a different network computer.
In a nutshell I have:
functionName() {
header('Content-type: application/excel');
header('Content-Disposition: attachment; filename="filename.csv"');
readfile('filename.csv');
HTML and php code to display the page
Then code to read the data from the database and write it to the file if the user clicks on the "save to excel"
button.
}
Like I said, if I do not use the headers, the file is written perfectly.
If I use the headers...the entire page, to include the html markup, buttons, everything, is written to the file.
So I am sure I am missusing the headers somehow.
Any suggestions?