Ciao a tutti,
è un argomento che è stato trattato qui sul forum ma non sono riuscito a far funzionare il tutto.
Lo script che segue genera correttamente un file excel ma è sempre vuoto (contiene solo le intestazioni delle colonne).
Codice PHP:
<?php
header('Content-type: application/vnd.ms-excel');
header("Content-disposition: attachment;filename=nomefile.xls");
$filename="export.xls";
?>
<!-- iniziamo a costruire la nostra tabella --/>
<html><head><title>Export</title></head><body>
<table border="1">
<tr>
<th>Data registrazione</th>
<th>Nome</th>
<th>Cognome</th>
<th>Segnalatore</th>
<th>Tutor</th>
<th>Servizio inviante</th>
<th>Stato</th>
</tr>
<?
require_once('config.php');
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$sql="select data_reg, nome, cognome, segnalatore, tutor, servinviante, stato FROM utenti WHERE idunivoco LIKE 'GVN%' ORDER BY data_reg ASC";
$query=@mysql_query($sql) or die (mysql_error());
while ($row=mysql_fetch_array($query))
{
$data_reg=$row['data_reg'];
$nome=$row['nome'];
$cognome=$row['cognome'];
$segnalatore=$row['segnalatore'];
$tutor=$row['tutor'];
$servinviante=$row['servinviante'];
$stato=$row['stato'];
?>
<tr>
<td><? echo $data_reg; ?></td>
<td><? echo $nome; ?></td>
<td><? echo $cognome; ?></td>
<td><? echo $segnalatore; ?></td>
<td><? echo $tutor; ?></td>
<td><? echo $servinviante; ?></td>
<td><? echo $stato; ?></td>
</tr>
<?
}
?>
</table>
</body>
</html>
<?
@mysql_close($link);
?>
Avete qualche idea in merito?
Grazie!!!
Tulipano