Need Help in Exporting mysqL to Excel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
symbianslave
Forum Newbie
Posts: 1
Joined: Sun Oct 04, 2009 7:36 pm

Need Help in Exporting mysqL to Excel

Post by symbianslave »

Hi Everyone,
Im new here and to PHP also (Though PHP has been around for a long time)

Can someone give me a sample of how to create a report in php which will export contents of msql data base into exel?I need to have something that will export only specific columns and not all of the columns (this can be hard coded,I dont need to make it dynamic)?I just dont know where to start learning this.

Also,I need to specify a date range for the report which should come from an html form with two date fields.
I have been looking for samples in the web but I culd not find something that I could understand bec Im used to asp and not php.

Regards to everyone
Thanks In advanced.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Need Help in Exporting mysqL to Excel

Post by Mark Baker »

A whole lot of questions

First off, create a form that allows for input of the two dates and then calls the report script;
in the report script, validate your input dates, connect to your database, build a SQL query that will retrieve the data that you want from the database based on those dates, retrieve that dat aand loop through each record... there are plenty of examples of how to do this around the net, here on the forum, or in the PHP manual at http://www.php.net.
For output to Excel, either output as a CSV file (Excel will read CSV files) or use a library such as PHPExcel if you need the data to be formatted in Excel
Post Reply