mysql - Concatenate static value while exporting CSV file using fputcsv in PHP -
i using below code export csv file using fputcsv in php. code works proper , csv file generates. values/records coming database. want add dollar ($) symbol of column values.
code exporting csv file.
$filename1 = "all months.csv"; ob_end_clean(); $fp1 = fopen('php://output', 'w'); ob_start(); header("content-type: application/vnd.ms-excel"); header('content-disposition: attachment; filename='.$filename1); fputcsv($fp1, array('month', 'year', 'total production', 'credit adjustments', 'net production', 'hygiene production', 'collections', 'account receivable total', 'new patients', 'break points', 'net income', 'hygiene %')); $query = $db->query("select month, year, total_production, credit_adjustments, net_production, hygiene_production, collections, ac_receivable_total, new_patients, break_even_points, net_income, hygiene clientsdata client_id = '".$userid."'"); while($row = $query->fetch(pdo::fetch_assoc)) { fputcsv($fp1, $row); } exit();
snapshot of exporting file -
if want add $ sign can way:
while($row = $query->fetch(pdo::fetch_assoc)) { $row['the_field_you_want'] = '$'.$row['the_field_you_want'] fputcsv($fp1, $row); }
Comments
Post a Comment