I'm creating a CSV file using php and what to extract data from mysql however each record needs to be on a new line and the current coding isn't doing this. Any suggestions?
<?php include "common/db_connect.php"; $date = date("Y-m-d"); $rand = rand(10000000000,999999999999999999); $query=mysql_query("SELECT * FROM `DPD` WHERE `date`='$date' AND `submitted`='0'"); $content=""; while($fetch_DPD=mysql_fetch_object($query)){ $content .= "".$fetch_DPD->ref.",".$fetch_DPD->date.",".$fetch_DPD->name.",".$fetch_DPD->add1.",".$fetch_DPD->add3.",".$fetch_DPD->add4.",".$fetch_DPD->post_code.",".$fetch_DPD->country_code.",".$fetch_DPD->service.",".$fetch_DPD->no_of_parcels.",".$fetch_DPD->weight.", ".$fetch_DPD->tele.", ".$fetch_DPD->SMS.", ".$fetch_DPD->email.", ".$fetch_DPD->value.", ".$fetch_DPD->description."" . PHP_EOL; $fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/admin/temp/".$rand.".csv","wb"); fwrite($fp,$content); fclose($fp); } ?>