Hi,
If you want to save it as an excel file (*.xls) I think there is a program in one of the code librarys (search google for excel export PhP).
But if it is just about having an excel readble format, you could just create an csv formatted file, which is not more/less then placing a , between field, or, if you suspect comma's in the individual fields, semi-colons (😉, or any other separator.
J.
ps: A snippet in one of my programs, to create a pipe-delimited file:
header("Content-type: application/txt");
// Met datum in de naam
$filename = "Registratie_GBM2005_".date("F_j_Y").".txt";
header("Content-Disposition: attachment; filename=$filename");
$filedata = "
#------------------------------------------------------------
# Deelnemers van GBM2005 ".date("F-j-Y")."
#------------------------------------------------------------
";
$yesarray = array(1);
$noarray = array(-1,0);
$showpartarray = array("P_id", "P_title","P_initials","P_name","P_fname","P_organisation","P_department",
"P_address","P_postal","P_city","P_country","P_phone","P_fax","P_email",
"P_category","P_student","P_presentation","P_oral","P_poster","P_forum","P_stand","P_none",
"P_inserted","P_finalreg", "P_updated", "P_payment", "P_cost", "P_train");
$results = mysql_query("select * from participants") or die('Geen gegevens beschikbaar');
while($row=mysql_fetch_array($results))
{
$thiscol=0;
$row2 = $row;
$header = "";
while (list ($key, $val) = each ($row2))
{
//echo $key;
$thiscol = $thiscol+1;
if(!in_array($key, $showpartarray))
{ }
else
{
if(($val=='1') and ($key <> 'P_id'))
{
$printval = 'Yes';
}
else
{
if(($val=='0') or ($val=='-1'))
{
$printval = 'No';
}
else
{
if ($key == "P_toegang")
{$printval = "******";}
else
{
$printval = $val;
}
}
}
if($key == "P_country")
{
$Cquery = "select * from country where Count_id=$val";
$Cresult = mysql_query($Cquery);
While($crow = mysql_fetch_array($Cresult))
{
$printval = $crow[Count_desc];
}
}
if(($thiscol == 1) and ($key ==0))
{
$header .= "";
$data .= "";
}
else
{
if($key == "P_updated")
{
$printval = substr($val, 0, 4)."-".substr($val, 4, 2)."-".substr($val, 6, 2);
}
$header .= $key."|";
$data .= "$printval"."|";
}
}
}
$data .="\r\n";
}
$data = $filedata."\r\n\r\n".$header."\r\n".$data;
break;
}
}
echo $data;