회원로그인
mySQL 자료 엑셀,워드,파워포인트로 다운받기
16년 전
<?
//include_once("./_common.php");
//if (!$is_admin =="super")
// alert_close("최고 관리자 영역 입니다.");
//include "dbconfig.php";
$mysql_host = "localhost";
$mysql_user = "디비 아이디";
$mysql_password = "디비 비밀번호";
$mysql_db = "데이타베이스";
$dbconn = mysql_connect("$mysql_host","$mysql_user","$mysql_password") or die("데이터베이스 연결에 실패하였습니다.");
mysql_select_db($mysql_db, $dbconn);
$filename = '파일이름';
if ($ms =="excel"){
$g4[title] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel; charset=utf-8" );
header( "Content-Disposition: attachment; filename=".$filename.".xls" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="power"){
$g4[title] = "파워포인트 문서 다운로드";
header( "Content-type: application/vnd.ms-powerpoint; charset=utf-8" );
header( "Content-Disposition: attachment; filename=".$filename.".ppt" );
// header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="word"){
$g4[title] = "워드 문서 다운로드";
header( "Content-type: application/vnd.ms-word; charset=utf-8" );
header( "Content-Disposition: attachment; filename=".$filename.".doc" );
//header( "Content-Description: PHP4 Generated Data" );
} else if ($ms =="memo"){
$g4[title] = "메모 문서 다운로드";
header( "Content-type: application/vnd.ms-notepad; charset=utf-8" );
header( "Content-Disposition: attachment; filename=".$filename.".txt" );
} else {
header( "Content-type: application/vnd.ms-excel; charset=utf-8" );
header( "Content-Disposition: attachment; filename=".$filename.".xls" );
}
header( "Content-Description: PHP4 Generated Data" );
// 검색어에 대해서 처리
$s_que="";
$temp=mysql_fetch_array(mysql_query("select count(*) from hp_doumi $s_que"));
// 정보를 구해옴
$result=@mysql_query("select * from hp_doumi $s_que order by idx desc");
// 앞에 붙는 가상번호
// $temp=mysql_fetch_array(mysql_query("select count(*) from hp_doumi $s_que"));
$number=$temp[0]
?>
<head>
<head>
<title><?=$g4[title]?></title>
<style type="text/css">
/* 엑셀 다운로드로 저장시 숫자로 표시될 경우 방지 */
.txt {mso-number-format:'\@'}
</style>
</head>
<body>
<table>
<tr>
<td>번호</td>
<td>봉사자명</td>
<td>생년월일</td>
<td>성별</td>
<td>결혼여부</td>
<td>나이</td>
</tr>
<?
while($data = mysql_fetch_array($result)) {
$idx = $data[idx];
$d_name = $data[d_name];
$d_birth = $data[d_birth];
$d_birth_ = explode("-",$d_birth);
$d_birth1 = $d_birth_[0];
$d_birth2 = $d_birth_[1];
$d_birth3 = $d_birth_[2];
$d_sex = $data[d_sex];
if ($d_sex == 'M') { $d_sex = '남'; }
if ($d_sex == 'F') { $d_sex = '여'; }
$d_marriage = $data[d_marriage];
if ($d_marriage == 'y') { $d_marriage = '기혼'; }
if ($d_marriage == 'n') { $d_marriage = '미혼'; }
$d_age = $data[d_age];
?>
<tr>
<td class='txt'><?=$idx?></td>
<td class='txt'><?=$d_name?></td>
<td class='txt'><?=$d_birth?></td>
<td class='txt'><?=$d_sex?></td>
<td class='txt'><?=$d_marriage?></td>
<td class='txt'><?=$d_age?></td>
</tr>
<?
$number--;
}
?>
</table>
</body>
</html>
추천 : 372
추천
목록