상품정보 액셀(엑셀, exel) 다운로드 소스
관련링크
본문
안녕하세요. 상품정보 액셀로 다운받기 파일을 만들려고 하는데요...
참고 사이트는 http://devcrunch.tistory.com/109 를 기본으로...
어떻게 코딩해야 하는지요.. 아시는 분들 좋은 정보 부탁드립니다.
감사합니다.
답변 2
<?
include_once("./_common.php");
$excel_down = "g4_write_" . $_GET['bo_table']; //엑셀 다운로드 테이블
$wr_id = $id = $_GET['wr_id'];
include "../../../dbconfig.php";
$db_conn = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die('서버에 접속하지 못했습니다.');
mysql_select_db($mysql_db, $db_conn);
//@mysql_query("SET CHARACTER SET utf8"); // 한글깨지면 주석해지
if ($ms =="excel"){
$g4[title] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=data.xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint" );
header( "Content-Disposition: attachment; filename=data.ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word" );
header( "Content-Disposition: attachment; filename=data.doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad" );
header( "Content-Disposition: attachment; filename=data.txt" );
} else {
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=clickmarketing.xls" ); // 파일명을 게시판 그룹명으로
}
header( "Content-Description: PHP4 Generated Data" );
$temp=mysql_fetch_array(mysql_query("select count(*) from $excel_down ")); //where wr_is_comment = '0' and wr_content = '$wr_id' "));
$result=@mysql_query("select * from $excel_down order by wr_datetime desc");// where wr_is_comment = '0' and wr_content = '$wr_id' order by wr_datetime desc");
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table border="1">
<tr>
<td>수</td>
<td>20<!--<?=number_format($total_count)?>--></td> <!-- 전체 게시글 수-->
<td></td>
<td></td>
<td>갯수</td>
<td>1</td>
</tr>
<?
while($data=mysql_fetch_array($result)) {
echo "
<tr>
<td>$number</td>
<td class='txt'>$data[wr_subject]</td>
<td class='txt'>$data[wr_1]</td>
<td class='txt'></td>
<td class='txt'>$data[wr_2]</td>
<td class='txt'></td>
</tr>
";
$number--;
}
?>
</table>
</body>
</html>
예제코드입니다. 쿼리나 해당 개수 및 폼등은 맞게끔 수정해야됩니다.
위 블로그 내용대로 적용하시면 됩니다.
답은 나와있네요~