data from mySQL into CSV for Excel?

This is a discussion on data from mySQL into CSV for Excel? within the PHP Language forums, part of the PHP Programming Forums category; I've a survey form that I need to get data from and put into a mySQL database. Easy, can ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-02-2003
LRW
 
Posts: n/a
Default data from mySQL into CSV for Excel?

I've a survey form that I need to get data from and put into a mySQL
database.
Easy, can do it eyes closed.

But, then I need to be able to take that same information and convert
it (either directly or pulling it back out from the database) into a
CSV (or any file for that matter) that can be easily imported, added
into an existing Excel database.

I've no idea how to do that. (I can query the database, that I can do,
and create recordsets, AND create text files, but I've never created a
CSV file before.)

Is there a source, a good Web site for example, that explains that
kind of process pretty well?

Thanks!
Liam
druid -at-celticbear -dot- com
Reply With Quote
  #2 (permalink)  
Old 10-03-2003
BKDotCom
 
Posts: n/a
Default Re: data from mySQL into CSV for Excel?

deja@celticbear.com (LRW) wrote in message news:<3a1d1813.0310021038.1c955051@posting.google. com>...
> I've no idea how to do that. (I can query the database, that I can do,
> and create recordsets, AND create text files, but I've never created a
> CSV file before.)
>
> Is there a source, a good Web site for example, that explains that
> kind of process pretty well?
>


Surely then you're familiar with the implode function?
http://www.php.net/manual/en/function.implode.php
See example 1

CSV is just a text file with the fields/columns separated by commas..
Reply With Quote
  #3 (permalink)  
Old 10-03-2003
RG
 
Posts: n/a
Default Re: data from mySQL into CSV for Excel?


"LRW" <deja@celticbear.com> wrote in message
news:3a1d1813.0310021038.1c955051@posting.google.c om...
> I've a survey form that I need to get data from and put into a mySQL
> database.
> Easy, can do it eyes closed.
>
> But, then I need to be able to take that same information and convert
> it (either directly or pulling it back out from the database) into a
> CSV (or any file for that matter) that can be easily imported, added
> into an existing Excel database.
>
> I've no idea how to do that. (I can query the database, that I can do,
> and create recordsets, AND create text files, but I've never created a
> CSV file before.)
>
> Is there a source, a good Web site for example, that explains that
> kind of process pretty well?
>
> Thanks!
> Liam
> druid -at-celticbear -dot- com



It's easy really.
Just get the data line by line and write the values sepearated by a comma.
Don't forget to put a linebreak at the end of each line
eg: $line[]="$name , $address \r\n";
Then loop through the $line array and write file.

Hope this helps
RG




Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:14 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0