$result_set = mysql_query($qry) or die(mysql_error());
 ***this has to be called before any headers are written to the browser.
header("Content-type: application/csv");
header("Content-Disposition: attachement; filename="YOURFILENAME.csv");

while ($record_set_array = each($result_set)) {
      print implode(",", $record_set_array) . "\n";
that should pretty much cover it.


                      "Martin E. Koss"                                                 
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                      ows.com>                 cc:                                     
                                               Subject:  RE: [PHP-DB] Save mySQL data 
into a CSV file.                                  
                      06/16/2003 12:22                                                 

I've heard or read about the headers somewhere but right now I sure could
use pointing in the direction of a step-by-step tutorial for extracting my
data into a CSV file and, of course, setting up the PHP file to handle it



-----Original Message-----
From: Dillon, John [mailto:[EMAIL PROTECTED]
Sent: 16 June 2003 2:06 PM
To: 'Martin E. Koss'
Subject: RE: [PHP-DB] Save mySQL data into a CSV file.

It's something to do with the header in the html page.

-----Original Message-----
From: Martin E. Koss [mailto:[EMAIL PROTECTED]
Sent: 16 June 2003 13:53
Subject: [PHP-DB] Save mySQL data into a CSV file.
Importance: High

I have a table with 1,008 columns in it and at it's peak it has up to 500
rows of data.
I want to enable my client to click on a link and the next thing they are
prompted with is 'Save or Open' (the CSV file).
The data will be compiled into a comma delimited CSV file but rather than
printed to the screen it would be best if the browser popped up asking
to save the 'filename.csv' file to. Once saved, the file can be opened in
Excel for analysis.

Where do I start to do this?



PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

CONFIDENTIAL: This e-mail, including its contents and attachments, if any,
are confidential. If you are not the named recipient please notify the
sender and immediately delete it. You may not disseminate, distribute, or
forward this e-mail message or disclose its contents to anybody else.
Copyright and any other intellectual property rights in its contents are
sole property of Cantor Fitzgerald.
     E-mail transmission cannot be guaranteed to be secure or error-free.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission.  If verification is required please request a hard-copy
     Although we routinely screen for viruses, addressees should check this
e-mail and any attachments for viruses. We make no representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that to ensure regulatory compliance and for the protection of
our customers and business, we may monitor and read e-mails sent to and
our server(s).

For further important information, please read the  Important Legal
Information and Legal Statement at

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to