So I'm in the final stages of finishing my project, and I am stumped on something. I figured there are enough PHP genii around here to give me a hand with this.
I am trying to output data from a table called data in mysql, to a tab delimited, text file. My problem is that the new line isn't being reflected. The tabs are, but no new lines
code:
$q = "SHOW COLUMNS FROM ".TBL_DATA."";
$result = $database->query($q);
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field']."\t";
$i++;
}
}
$csv_output .= "\n";
$q2= "SELECT * FROM ".TBL_DATA." WHERE ListID = '$listingsort'";
$values = $database->query($q2);
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j]."\t";
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/octet-stream");
header("Content-disposition: attachment" . date("Y-m-d") . ".txt");
header( "Content-disposition: filename=".$filename.".txt");
echo $csv_output;
I've tried everything I could think of/googling. I have no idea what is going wrong and any help would be much appreciated