Export CSV from Mysql

前端 未结 5 1015
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 06:04

I\'m having a bit of trouble exporting a csv file that is created from one of my mysql tables using php.

The code I\'m using prints the correct data, but I can\'t see ho

5条回答
  •  [愿得一人]
    2021-01-27 07:03

    You can't have text and a download on the same page. You need to have a link to the download area, which could just be a GET parameter leading to a function, which then does all the processing, displays headers, and echoes the content of the CSV.

    For example, you could have Click here to download CSV, then in your code have if ($_GET['action'] === 'download'), get the data from the database, format it, send the headers, and echo the data. And then die(), because that part of the script can accomplish no more.

提交回复
热议问题