PHP & Others

DB내용 EXCEL로 변환

페이지 정보

본문

헤더 써서 하거나, csv로 파일 만들거나..

<?
require_once("dbconn.php");

header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=myfile.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);
?>

tip & tech 에서 검색해서 참고하기

관련자료

등록된 댓글이 없습니다.
Today's proverb
손톱만한 냉이꽃이 함박꽃이 크다고 하여 기죽어 피지 않는 일이 있는가. 사람이 각기 품성대로 능력을 키우며 사는 것, 이것도 한 송이의 꽃이라고 나는 생각한다. 《스무 살 어머니》 (정채봉)