意外结束文件错误并找到错误,任何人对此代码的建议/帮助主要是问题是关闭并得到相同的错误。
<?php
$connect = mysqli_connect("localhost", "root", "", "funrun");
$output = '';
if(isset($_POST["export_excel"]))
{
$sql = "SELECT * FROM registered ORDER BY fname DESC";
$result = mysqli_query($connect, $sql);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Address</th>
<th>Age</th>
<th>Gender</th>
<th>BIB NO.</th>
<th>Category</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["fname"].'</td>
<td>'.$row["mname"].'</td>
<td>'.$row["lname"].'</td>
<td>'.$row["address"].'</td>
<td>'.$row["age"].'</td>
<td>'.$row["gender"].'</td>
<td>'.$row["bib_no"].'</td>
<td>'.$row["category"].'</td>
</tr>
';
}
$output .= '</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=download.xls);
echo $output;
}
}
?>
任何人都有建议和评论请评论(仍在这里学习)
答案 0 :(得分:1)
你输掉了"
&#39;在你的标题中()。
header("Content-Disposition: attachment; filename=download.xls);
应该是
header("Content-Disposition: attachment; filename=download.xls");