I want to export my table to Excel but I have a problem, only in smarthphones don't go worked and keep showing me the same error.
In addition to saying that the file is corrupted, it keeps giving an error on the form when I download it for cell phones.
list.php
<form method="post" action="export.php">
<input type="submit" name="export" class="btn btn-success" value="Export" />
</form>
export.php
<?php
//export.php
$connect = mysqli_connect("localhost", "root", "", "contador");
$output = '';
if(isset($_POST["export"]))
{
$query = "SELECT * FROM contador";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>ID</th>
<th>RequestID</th>
<th>Acessos</th>
<th>Cidade</th>
<th>Data</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["ID"].'</td>
<td>'.$row["Nome"].'</td>
<td>'.$row["Acessos"].'</td>
<td>'.$row["Cidade"].'</td>
<td>'.$row["Data"].'</td>
</tr>
';
}
$output .= '</table>';
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename=listaAcessos.xls');
echo $output;
}
}
?>