2010년 3월 10일 수요일

DB데이터를 엑셀파일로 출력시키기

[code php]require_once(\"dbconn.php\"); header( \"Content-type: application/vnd.ms-excel\" ); header( \"Content-Disposition: attachment; filename=$filename.xls\" ); header( \"Content-Description: PHP4 Generated Data\" ); $sql = \"SELECT * FROM tableName\"; $stmt = mysql_query(\"$sql\",$conn) or die(mysql_error()); while ($row = mysql_fetch_row($stmt)){ echo (\"$row[0] $row[1] $row[2] $row[3] ... \\r\\n\"); } mysql_free_result($stmt); mysql_close($conn);[/code]

댓글 없음:

댓글 쓰기