You are here: Re: How to convert MYSQL data result to csv file format. « All PHP « IT news, forums, messages
Re: How to convert MYSQL data result to csv file format.

Posted by NN on 12/31/07 15:56

thank you!. i'll try it and see if it works on my server.

thanks,
NN

>On Dec 29, 7:22 am, NN <NoN...@home.com> wrote:
>>
>> i tried the script and it works great!
>> i have a question. i added a link to download the file created with
>> the url of the file. when i run it on my wamp server i click on the
>> link and it prompts me to save the file, when i run it on my web
>> server the csv opens in the browser instead of prompting to save the
>> file.
>> any idea of how to solve this?
>> does it have to do with the php.ini settings?
>
>No, it has to do with HTTP headers Web servers send out before serving
>actual data.
>
>How do you solve this? By writing a script that would send the
>appropriate headers and then dump the data. Let's assume that, in
>line with the previous example, you have created a file called
>data.csv. Now you can write a script that will serve this data and
>suggest to the browser that the data is to be saved as data.csv rather
>than viewed in the browser:
>
>header('Content-type: application/vnd.ms-excel');
>header('Content-disposition: attachment; filename=data.csv');
>readfile('data.csv');
>
>Note, however, the word "suggest" above; the browser may choose to
>ignore the "Content-disposition:" header and still display data in
>browser of save it under the script's name rather than as data.csv...
>
>Cheers,
>NC

 

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

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