drazvzi741287 2012-07-12 14:02
浏览 34
已采纳

使用mysql下载PHP生成的CSV / PDF

I have a form that generates an SQL statement, based on the users choices. It is functioning much like the report wizard in MS Access. On the last step, I have all the data, and the dynamically generated SQL query, but I need a way where they can download it as a file. How should I go about this?

Currently I have three buttons called 'View Results' (which just shows HTML generated results, that is easy - they just open up in a new tab)

'Download CSV' (preferably I would like this when clicked to just act like a normal download of a file, the user gets prompted to save as etc by the browser)

'Download PDF' (same as CSV)

At the moment when the CSV button is pressed a new tab opens up with export_report.php, which outputs CSV style report data.

How can I achieve the desired results with the CSV and PDF button? I have all the data and information I need to generate either but I am unsure how to proceed forward with this.

  • 写回答

1条回答 默认 最新

  • dsh7551 2012-07-12 14:29
    关注

    For the generation of the PDF you could use fpdf witch allows you to build a pdf from php.

    For the generation of the CSV you only have to adjust the headers. Here is a link that explains how this works: csv generation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制