Articles: 843 | Categories: 148   
   
   
Home Articles Contact Us
 
 
 
 
Creating A .csv Document (0 Comments)
Admin: Posted Date: March 3, 2010

This is a very basic script for creating a .csv file in PHP and is easy to set up and display information. I hope this helps you out in displaying data! You can aslo set it up to display MySQL results too!

Creating A .csv Document With PHP

This is a very basic script for creating a .csv file in PHP and is easy to set up and display information.

The Script

OK, here's the whole script. I'll explain how it works after:

<?php
header ("Content-type: application/csv
Content-Disposition: "inline; filename=dates_of_year.csv"");
echo "Day,Month,Year";
echo "1,6,2011";
echo "3,11,2011";
echo "19,2,2011";
?>

As you can see it is very basic. It will look something like this when you open the .csv file:

 

Day Month Year
1 6 2011
3 11 2011
19 2 2011

How It Works

Very simple. For every box(See above) you want to display information in, you need to add a comma(,):

Day,Month,Year

And for every "break", you need to add a forward slash and the letter n:

\n

Hope that helps you out in displaying data! You can aslo set it up to display MySQL results too!

Enjoy!

 

 

 
 
Add a Comment:
 
(You must be signed in to comment on an article. Not a member? Click here to register)
   
Title:

Comments: