Create a CSV File for a user in PHP

前端 未结 19 2035
故里飘歌
故里飘歌 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:21

    Put in the $output variable the CSV data and echo with the correct headers

    header("Content-type: application/download\r\n");
    header("Content-disposition: filename=filename.csv\r\n\r\n");
    header("Content-Transfer-Encoding: ASCII\r\n");
    header("Content-length: ".strlen($output)."\r\n");
    echo $output;
    

提交回复
热议问题