2
I’m having doubts regarding generating an excel with the query.
<?php
include("conectar.php");
$id = $_GET['id'];
$arquivo = 'Não autorizado .xls';
First question is this: In the $file part I can put a variable to rename the file?
// -- Cabeçalho do arquivo -------------------------------------
$html .= '<tr><td align="center"><b>Instalador</b></td>';
$html .= '<td align="center"><b>Morada</b></td>';
$html .= '<td align="center"><b>Email</b></td>';
$html .= '<td align="center"><b>Validade</b></td>';
</tr>';
for($i=1; $i<=$aux; $i ++){
$sql = mysql_query("SELECT tb_trabalhador.Nome,Morada,Email,Validade from
tb_detalhe_trabalhador inner join tb_trabalhador on
tb_detalhe_trabalhador.id = tb_trabalhador.id inner join
tb_equipamentos on tb_detalhe_trabalhador.id = tb_equipamentos.id
inner join tb_funcoes on tb_detalhe_trabalhador.id = tb_funcoes.id
WHERE tb_trabalhador.id = $id = ".$i) or die(mysql_error());
$row=mysql_fetch_array($sql);
$html .= '<tr><td>'.$row[0].'</td><td>'.$row[1].'</td>
<td>'.$row[2].'</td><td>'.$row[3].'</td></tr>';
}
$html .= '</table>';
The second question is: I will export data to Excel with many dates. It is possible for me to export the data to Excel and where the dates have been passed in relation to today’s day become a red rectangle?
Your very broad question could be more specific?
– user6026
What is the doubt? Can you tell me to try to explain better?
– ChrisAdler
Well I have the routine that does this, takes a data from the Mysql database and generates a xls ouput, which you get as a download via browser, all generated by PHP... would that be it? You need a code that generates an xls (excel)?
– user6026
I have the code that gives me Excel. But when generating Excel it has to have a name, in that name I want to put the name of a variable
– ChrisAdler
Of course, it can, but to get to this page and this code as you do, and in your question you have two doubts? On Monday if you’re going to have to change the code, wouldn’t it be nice to send your code in the body of the question?
– user6026
I have now placed in the body of the question the code
– ChrisAdler