Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Export data with Dreamweaver (TXT, CSV)

New Here ,
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

Hi to all of the Adobe community.

My question to me is a little hard for my level of knowledge.

I'm using Dreamweaver using technology PHP / MySQL, in my database have a table in MySQL called mailing list, with the fields name and email.

I have a php page that I developed using the Dynamic Table where it returns me a list of names and e-mail registrations. What I would like to make is that at the end of this table I have a link or a button called export data. I wish that when you export this data be txt or csv format.

How?

Export data and further define the format to be exported.

I'm using Dreamweaver CS4.

Rodrigo Vieira da Silva Eufrasio
E-mail: rodrigo.mct @ gmail.com
Mobile: +55 11 8183-9484
Brazil - Osasco - SP

TOPICS
Server side applications

Views

1.9K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2011 Jan 19, 2011

Copy link to clipboard

Copied

LATEST

It is doable.

Assume for the moment that you are not paging the query results (that is, you are display ALL results at one time).

You would need to do the following when the button is clicked (the action calling a separate file for the processing):

    1. Open a file on the server for writing ($ofile = fopen("data.txt","w");)
    2. Repeat your query but instead of echo $row_Record set.... you would use fwrite($ofile, $row_Recordset...
    3. In between fields you would need fwrite($ofile, "\t") to put in a tab or fwrite($ofile, ",") for a CSV,
    4. At the end of every line you would need a <cr><lf>: fwrite ($ofile, "\r\n");
    5. Close the file - fclose ($ofile);
    6. Then use the header function to force the download of this file like this.
      1. header('Content-disposition: attachment; filename=data.txt');
      2. header('Content-type: text');
      3. readfile('data.txt);

The header function has to be the first thing sent to the user. Any white space would cause it to fail. I haven't tried this part after a DB query, but it should work. If it doesn't you will have to invoke the header routine in a separate file.

Hope this helps.

Barry


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines