如何在PHP中執行此操作?在csv formate中導出表數據並存儲到文件夾
我不想在csv文件中導出表格數據,而是在備份文件夾中存儲csv文件。
此我使用此:
$query = "SELECT * FROM `login_details`";
$file_name = "login_details";
$sql_csv = mysql_query($query) or die("Error: " . mysql_error()); //Replace this line with what is appropriate for your DB abstraction layer
header("Content-type:text/octect-stream");
$done = header("Content-Disposition:attachment;filename=$fileName");
while($row = mysql_fetch_row($sql_csv)) {
print '"' . stripslashes(implode('","',$row)) . "\"\n";
}
感謝。
你應該看看[fputcsv()](http://www.php.net/manual/fr/function.fputcsv.php) – Brewal