Ciao,
tramite un tutor on line sono riuscito a fare questo semplice script che mi esporta una query di mysql in excel ...

Funziona correttamente tutto l'unico problema che non risolvo è il fatto che io vorrei che mi mettesse la query su 4 righe e invece me le mette tutte su una... vi posto lo script spero che qualcuno possa aiutarmi ...

<html>
<head>
<body>



<div class="content">
<form id="form1" name="form1" method="post" action="esporta_news_letter.php">




<input type="submit" name="submit" id="submit" value="Esporta tab news letter excel" />
</p>
</form>
</div>


Codice PHP:
<?php 

$host 
'localhost';
$user 'db';
$pass 'db';
$db 'db';
$table 'news_letter';
$file 'export';

$link mysql_connect($host$user$pass) or die("Can not connect." mysql_error());
mysql_select_db($db) or die("Can not connect.");

$result mysql_query("SHOW COLUMNS FROM ".$table."");
$i 1;
if (
mysql_num_rows($result) > 0) {
while (
$row mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."; ";
$i++;
}
}
$csv_output .= "\n";

$values mysql_query("SELECT * FROM ".$table."");
while (
$rowr mysql_fetch_row($values)) {
for (
$j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j]."; ";
}
$csv_output .= "\n";
}

$filename $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" date("Y-m-d") . ".csv");
header"Content-disposition: filename=".$filename.".csv");
print 
$csv_output;
exit;
?>