I have all the necessary code but this is giving an error and has to do with $i
. How can I fix it?
<?php
include('conetar.php');
$query = "SELECT nome, contacto FROM utilizadores";
$executar_query = mysqli_query($conn, $query);
$contar = mysqli_num_rows($executar_query);
for($i=0;$i<1;$i++){
$html[$i] = "";
$html[$i] .= "<table>";
$html[$i] .= "<tr>";
$html[$i] .= "<td><b>Nome</b></td>";
$html[$i] .= "<td><b>contacto</b></td>";
$html[$i] .= "</tr>";
$html[$i] .= "</table>";
}
$i = 1;
while($ret = mysqli_fetch_array($executar_query)){
$retorno_nome = $ret['nome'];
$retorno_contacto = $ret['contacto'];
$html[$i] .= "<table>";
$html[$i] .= "<tr>";
$html[$i] .= "<td>".$retorno_nome."</td>";
$html[$i] .= "<td>".$retorno_contacto."</td>";
$html[$i] .= "</tr>";
$html[$i] .= "</table>";
$i++;
}
$arquivo = 'soudev.xlsx';
header ("Expires: Mon, 26 Jul 2100 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ("Content-type: application/x-msexcel");
header ("Content-Disposition: attachment; filename={$arquivo}" );
header ("Content-Description: PHP Generated Data" );
for($i=0;$i<=$contar;$i++){
echo $html[$i];
}
?>