ok what you want to do is this...
- write the report to the server
- get the report to the client. there is a way of doing this, where you open the file to the browser, but instead of displaying the file, you force the browser to bring up a save dialog so the file can be saved by the client.
i took this from [man]header[/man]...
<?php
header("Content-Disposition: attachment; filename=downloaded.csv");
//output csv file here
?>
if you save this file as getreport.php, when someone browses to getreport.php a dialog box will open asking them to save the file and suggesting a name.
nb you can only send headers at the start of an html file - i.e. before you echo <head> in the html. sending headers after the start of html will cause an error.
hope that helps!
adam