Nov 15, 2005 #1 jestrada101 Technical User Joined Mar 28, 2003 Messages 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
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
Nov 15, 2005 1 #2 Borvik Programmer Joined Jan 2, 2002 Messages 1,392 Location US 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. Upvote 0 Downvote
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.
Nov 15, 2005 Thread starter #3 jestrada101 Technical User Joined Mar 28, 2003 Messages 332 Perfect!!! Thanks! JE Upvote 0 Downvote