The following code output the sql query result into a csv file :
CODE
<?php
// Report all errors except E_NOTICE
error_reporting(E_ALL ^ E_NOTICE);
//connection file
include("connection.php");
$query = 'SELECT resting_blood_sugar,serum_cholesterol,thalach,oldpeak,result,date from hd_test WHERE patient_id = 2';
$output = fopen('N:\oldpatientgraph.csv', 'w');
$result = mysqli_query($link,$query);
// loop over the rows, outputting them
while ($row = mysqli_fetch_assoc($result)) fputcsv($output, $row);
?>
OUTPUT
The csv file contains output in following format :
1,1,1,1,1,11-1-2015 #line1
2,3,1,4,2,1-1-2000 #line2
Whereas i want to output the result in one line as follows :
1,1,1,1,1,11-1-2015,2,3,1,4,2,1-1-2000 #line1
Anyone here who knows how to do this ??