【发布时间】:2011-05-25 18:06:21
【问题描述】:
我有一个显示 html 表单的 php 文件,在提交时,从 mysql 数据创建一个 html 表,并将其导出到 excel。
我的问题是整个html表单和表格数据一起输出到excel文件中。
我的代码是:
<html form..>
<?php
if(isset($_POST['submit'])){
//get sql data and create html table in variable (ie $data="<table>..")
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo "$data";}
?>
我只想在我的 .xls 中显示“$data”,而是显示整个 <form>,提交按钮等等。
谢谢。
【问题讨论】:
-
谢谢@shakti-singh @marcin-cylke @inquam 很好的答案和快速的回复!我的脚本现在运行良好!