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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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.. |
|
|||
|
"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 |