作者nbaby19 (sh~~)
看板PHP
標題[請益] 資料表裡的資料寫入excel
時間Mon Sep 3 19:44:51 2007
要把資料表3個欄位(department,education,class)的所有值寫到excel裡
我要讓excel裡的資料看起來是
| number
3個欄位的值 |
3個欄位... |
3個欄位... |
|
以下是當中一段程式
因為寫入excel的方法我第一次用
所以不對的地方請指正
還有就是..excel檔開起來
$row["department"] $row["education"] $row["class"] 是亂碼且只顯示一列@@
//------------------------------------
$sql = "SELECT * FROM xxx ";
$result = mysql_query($sql, $link);
$row = mysql_fetch_array($result);
$string="\tnumber";
for( $i=1;$i<=mysql_num_rows($result);$i++ )
{$stringg="\n ".$row["department"]." ".$row["education"]."
".$row["class"]." \n ";
$row = mysql_fetch_array($result);
}
$fp = fopen("texcel.xls", "w");
fputs($fp,$string.$stringg);
fclose($fp);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.64.183.208
推 alpe:寫成csv吧 09/03 21:47