471,887 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

exporting a mysql table to excel format via a php program

Hi all

I have a php program accessing a mysql database. I want users to be able to run reports via the program. But I also want to export the results of my query to excel by clicking on a push button present on my screen. Is there any function which can do the export to excel format. I would be grateful if anyone could provide me this info.

Thanks
Jul 12 '07 #1
1 1557
code green
1,726 Expert 1GB
There probably is a class kicking around that will achieve this, but it is very easy to write to a CSV file using the fopen(), fwrite() php functions.
Place the data within a string with the data fields seperated by commas and each record terminated with carriage return newline.
ie
[PHP]$handle = fopen('filename','w');
fwrite($handle,"data1,data2,data3,data3 \r\n");
fclose();[/PHP]
Jul 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Andy Levy | last post: by
2 posts views Thread by Mustufa Baig | last post: by
1 post views Thread by Mustufa Baig | last post: by
3 posts views Thread by | last post: by
6 posts views Thread by Kevin Humphreys | last post: by
6 posts views Thread by Kevin Chambers | last post: by
5 posts views Thread by Dawid Pustulka | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.