Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV File 1

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
Is there a way to create a CSV file using PHP and pulling the data from MySQL? Any ideas that could guide me?

Thanks!
JE
 
Yes there is a way to do this.

We currently do it from a MSSQL table so a MySQL table shouldn't be much different.

First you want to make sure the proper header goes out:
Code:
Header("Content-type: text");
Header("Content-Disposition: attachment; filename=invoice.nonedi.zzprecdata");

Then as your going through your records, just output them like you would to the screen.

Code:
echo "$Field1,$Field2,$Filed3,$Fieldn\n";

And when your php finally finishes executing your download is complete.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top