You are here: Re: Output as csv « PHP Programming Language « IT news, forums, messages
Re: Output as csv

Posted by Bent Stigsen on 03/12/06 15:45

Geoff Berrow wrote:
> I'm trying to output the results of a database query as a csv file
>
> The DB output is in $csv
>
> foreach($csv as $array){
> $line[]=implode($delimited_by,$array)."\n";
> }
> header("Content-Type: text/plain");
> header("Content-Disposition: inline");
>
> foreach($line as $output){
> print $output;
>
>
> On clicking the link to this file the results are output to the screen.
> I can right click and save the output but I'm prompted to save it as a
> .php file. How can I make it output as the right kind ( .csv) of file?

There is a rfc stating "text/csv" as the mime-type, but it is quite
recent, so probably not widely recognized.
http://www.rfc-archive.org/getrfc.php?rfc=4180

Presently, I think the common way is to set disposition to attachment
and supply a filename, and let the OS figure out how to open it.
header('Content-Disposition: attachment; filename="foo.csv"');


/Bent

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация