469,344 Members | 5,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

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 1471
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.