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 -

enter image description here

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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -