Create a CSV File for a user in PHP

前端 未结 19 2066
故里飘歌
故里飘歌 2020-11-22 11:52

I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.

I have the e-mailing of the link, MySQL query, etc. covered.

<
19条回答
  •  眼角桃花
    2020-11-22 12:15

    The thread is a little old, I know, but for future reference and for noobs as myself:

    Everyone else here explain how to create the CSV, but miss a basic part of the question: how to link. In order to link to download of the CSV-file, you just link to the .php-file, which in turn responds as being a .csv-file. The PHP headers do that. This enables cool stuff, like adding variables to the querystring and customize the output:

    Get CSV
    

    my_csv_creator.php can work with the variables given in the querystring and for example use different or customized database queries, change the columns of the CSV, personalize the filename and so on, e.g.:

    User_John_Doe_10_Dec_11.csv
    

提交回复
热议问题