Export CSV example code in PHP
Export CSV example code in PHP
if($report=="credit-redeemed")
{
$csv_file = 'mcv_'.$report.'_report.csv';
$output="Username, Total credit purchased, Total $ amount of credit claimed/redeemed, Total $ amount received for credit left/unused \r\n";
$result = get_credit_purchased(1);
while($node=db_fetch_object($result)){
$redeemed_amount = get_redeemed_amount_by_uid($node->uid);
$left_credit = ($node->total_amount)-$redeemed_amount;
// values separated by comma
$output.=ucfirst($node->name).',$ '.round($node->total_amount,2).',$ '.round($redeemed_amount,2).',$ '.round($left_credit,2)."\n";
}
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$csv_file");
header("Accept-Ranges: bytes");
echo "$output";

Post a Comment