我嘗試寫一個男女同校的在那裏我有我的數據庫的內容導出到一個CSV文件出口MySQL數據庫(與數字數據)到csv
與數字的出口已經作品但是我導出CSV是有問題
例如我的SQL數據庫看起來像這樣
telephone number
+639063073755
但是在導出CSV從電話號碼的數據變成這樣
telephone number
6.39063E+11
的電話號碼變成指數
有沒有辦法在這裏解決這個
是我的代碼
$sql = DB::query("SELECT * FROM table 1 order by id ASC");
$col2 = DB::query("SELECT * FROM table2 order by col_id ASC");
$rp_name = DB::queryOneField('rp_name',"SELECT * FROM report_presets where rp_id=%i",$_GET['rp_id']);
$rp_name = str_replace(" ","",$rp_name);
$line1 .= "Telephone Number";
foreach($sql as $row){
$line2 .=
str_replace(",","",$row[mobile_no]). ","
."\n";
}
$data="$line1\n$line2\n";
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=".$rp_name.".csv");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
感謝
它是否真的在原始CSV內容中顯示「6.39063E + 11」(在純文本編輯器中查看)?或者是你的軟件改變它(即Excel)。 – MrCode
即時通訊使用excel。我想問題出在excel謝謝你的回答 – itsover9000
在發送到CSV文件之前將音樂會數字轉換爲字符串,並在檢索之前將其轉換回很長 –