hi all, i'm trying to add an extra column to the exported excel file - "Gross" which is calculated as 3.99*numcalls where numcalls is obtained from my query. however, i don't know where to insert my calculation or display the additional calculated values. so far i only managed to add the "Gross" header. any advise? here's my codes:
$query3 = "SELECT Date, FLOOR(SUM(FLOOR(Duration)/60)) as DurationMin, Count(*) as numcalls
FROM adventus_record
GROUP BY Date";
$gross = "Gross";
$grossRev = $numcalls*3.99;
$export = mysql_query($query3);
$fields = mysql_num_fields($export);
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}
//i managed to do this...
$header .= $gross."\t";
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
//--------------------------------------- check for blanks or quotes and remove ------------------------------------
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
//--------------------------------------- end --------------------------------------------------------------------------------
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);
$name = $month.$year."Stats";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";[/COLOR]