You can also often just save the file as HTML and load it directly in Excel, if all you need is the export.

Sean

On Jun 8, 2005, at 5:48 AM, Thomas Bätzler wrote:

Sara <[EMAIL PROTECTED]> suggested:
I always used 'phpmyAdmin' for such tasks. Give it a try.

Great idea! That's like handing loaded guns to people
while telling them to keep them pointed at their feet ;-)

But to get back to Glauco's message:

I do a query to mysql table and view the result in
html table. At this point I want export query result
in a text file (comma separated fields), doing to
choose (to user) file name and destination on your
filesystem.
Can you help me?

This is off the top of my head, but it might get you started:

#!/usr/bin/perl

use strict;
use warnings;
use CGI;

my $q = new CGI;

# processing goes here

if( $q->param('mode') || '' eq 'csv' ){
  print $q->header('text/csv');
  # output data as CSV
} else {
  print $q->header .
  $q->start_html;
  # output data as html
  # create a link to self
  $q->param(-name=>'mode',-value=>'csv');
  print $q->p( $q->a({href=>$q->self_url},"Download as CSV") );
  print $q->end_html;
}

__END__

HTH,
Thomas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to