//RIGHE CONNESSIONE AL DB
$nomefile = "Report" . $date . ".xls";
$file = fopen($nomefile, "w");
//TABLE HEADS
$value .= '<table border="1">';
$value .= '<tr>';
$value .= '<th width="80">COL1</th>';
$value .= '<th width="111">COL2</th>';
$value .= '<th width="45">COL3</th>';
$value .= '<th width="80">COL4</th>';
$value .= '<th width="70">COL5</th>';
$value .= '<th width="50">COL6</th>';
$value .= '<th width="130">COL7</th>';
$value .= '<th width="55">COL8</th>';
$value .= '</tr>';
//TABLE ROWS
$i=1;
while ($row = mysql_fetch_array($result))
{
$value .= '<tr>';
$value .= '<td>'.$row[DATO1].'</td>';
$value .= '<td>'.$row[DATO2].'</td>';
$value .= '<td>'.$row[DATO3].'</td>';
$value .= '<td>'.$row[DATO4].'</td>';
$value .= '<td>'.$row[DATO5].'</td>';
$value .= '<td>'.$row[DATO6].'</td>';
$value .= '<td>'.$row[DATO7].'</td>';
$value .= '<td>'.$row[DATO8].'</td>';
$value .= '</tr>';
}
$i ++;
$value .= '</table>';
fwrite($file, $value);
fclose($file);