Click to See Complete Forum and Search --> : Extracting MySQL databse and saving it as excel to disk..URGENT HELP!!!
j-dearden
07-27-2006, 06:02 AM
Hey could any one please tell me if it is possible to extract my mysql database and save the file as a excell spreadsheet so that it can be printed?
i need a script that can do this so i can impliment it into my site cheers.
Sid3335
07-27-2006, 08:12 AM
you can write the results of a mysql query to a spreadsheet like this:
while($row = mysql_fetch_assoc($result))
{
$data .= $row['item1'] . "\t" ;
$data .= $row['item2'] . "\t" ;
$data .= $row['item3'] . "\t" ;
$data .= $row['item4'] . "\t" ;
$data .= $row['item5'] . "\t" ;
$data .= $row['final item'] . "\n" ;
}
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=analysis.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
\t will tab to the next field in the spreadsheet.
should get you started