ti posto il codice della pagina:

codice:
mysql_select_db($database_conn, $conn);
$query_rec_clienti = "SELECT * from tb_libri ORDER BY titolo ASC";
$result = mysql_query($query_rec_clienti, $conn) or die(mysql_error());
$totalRows_rec = mysql_num_rows($result);

header("Content-type: application/vnd.ms-excel");
header("Content-disposition: nomefile.xls; filename=prova.xls");



$campi = "";
for ($i = 0; $i < mysql_num_fields($result); $i++)
{
	$campi .= mysql_field_name($result,$i)."\t";
}
print(trim($campi));
	print "\n";
	print "\n";
while($row = mysql_fetch_row($result))
{
	$schema_insert = "";
	for($j=0; $j<mysql_num_fields($result);$j++)
	{
		
		$schema_insert .= $row[$j].$sep;
		
	}
	
	$schema_insert = str_replace($sep."$", "", $schema_insert);
	$schema_insert = preg_replace("/rn|nr|n|r/", " ", $schema_insert);
	$schema_insert .= "t";
	print(trim($schema_insert));
	print "\n";
}