php - Export MySQL to CSV -


i have below script export mysql data csv file.this script export inside while loop want put constant value in 2nd column or want keep 2nd column empty , put mysql data in column 1 , column 3.

// output column headings fputcsv($output, array('column 1', 'column 2', 'column 3'));  // fetch data $rows = mysql_query('select field1,field2 table');  // loop on rows, outputting them while ($row = mysql_fetch_assoc($rows)) fputcsv($output, $row); 

you have field1 (i.e-column1) , field2(i.e-column3)
add null @ 2nd position below

$insert = array( '' ); array_splice( $row, 1, 0, $insert );   

then use

fputcsv($output, $row); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -