Hi all, currently i am working on a script that write mysql results to excel file. I got a class that handle MSExcel Stream, but the only problem is I dont know how to loop the mysql results into an associative array like what the script do in the example.
Here's the sample code i got, the highlight part is what i want to change:
<?php
require_once "excel.php";
$export_file = "xlsfile://tmp/example.xls";
$fp = fopen($export_file, "wb");
if (!is_resource($fp))
{
die("Cannot open $export_file");
}
$assoc = array(
array("Sales Person" => "Sam Jackson", "Q1" => "$3255", "Q2" => "$3167", "Q3" => 3245, "Q4" => 3943),
array("Sales Person" => "Jim Brown", "Q1" => "$2580", "Q2" => "$2677", "Q3" => 3225, "Q4" => 3410),
array("Sales Person" => "John Hancock", "Q1" => "$9367", "Q2" => "$9875", "Q3" => 9544, "Q4" => 10255),
);
fwrite($fp, serialize($assoc));
fclose($fp);
?>
Anyone can help? Thanks in advance.