글
<?
$connect_host = "localhost";
$connect_id = "디비아이디";
$connect_pass = "디비비밀번호";
$connect_db = "디비명";
$connect_table = "gb_member";//저장할테이블명을 적으시오...
$xls_filename = "filename.xls";
$connect=@mysql_connect($connect_host,$connect_id,$connect_pass);
$mysql=@mysql_select_db($connect_db,$connect);
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=memberDB.xls" );
?>
<table style="border-width:1; border-color:green; border-style:dotted;">
<tr align=center>
<?
$fields = mysql_list_fields("$connect_db", "$connect_table");
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
$field[$i]=mysql_field_name($fields, $i);
echo "<th>".$field[$i]. "</th>";
}
?>
</tr>
<?
$result=mysql_query("select * from $connect_table");
while($data=mysql_fetch_assoc($result)){
echo"<tr>";
for ($i = 0; $i < sizeof($field); $i++) {
echo "<td style='border-width:1; border-color:green; border-style:dotted;'>".$data["$field[$i]"]."</td>";
}
echo"</tr>";
}
?>
</table>
한글이 깨지는 경우는 위 내용중
아래부분 붉은색 추가.. =====================================================
header( "Content-type: application/vnd.ms-excel;" );
header( "Content-Disposition: attachment; filename=data.xls" );
?>
<table style="border-width:1; border-color:green; border-style:dotted;"> <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
$connect_host = "localhost";
$connect_id = "디비아이디";
$connect_pass = "디비비밀번호";
$connect_db = "디비명";
$connect_table = "gb_member";//저장할테이블명을 적으시오...
$xls_filename = "filename.xls";
$connect=@mysql_connect($connect_host,$connect_id,$connect_pass);
$mysql=@mysql_select_db($connect_db,$connect);
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=memberDB.xls" );
?>
<table style="border-width:1; border-color:green; border-style:dotted;">
<tr align=center>
<?
$fields = mysql_list_fields("$connect_db", "$connect_table");
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
$field[$i]=mysql_field_name($fields, $i);
echo "<th>".$field[$i]. "</th>";
}
?>
</tr>
<?
$result=mysql_query("select * from $connect_table");
while($data=mysql_fetch_assoc($result)){
echo"<tr>";
for ($i = 0; $i < sizeof($field); $i++) {
echo "<td style='border-width:1; border-color:green; border-style:dotted;'>".$data["$field[$i]"]."</td>";
}
echo"</tr>";
}
?>
</table>
한글이 깨지는 경우는 위 내용중
아래부분 붉은색 추가.. =====================================================
header( "Content-type: application/vnd.ms-excel;" );
header( "Content-Disposition: attachment; filename=data.xls" );
?>
<table style="border-width:1; border-color:green; border-style:dotted;"> <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
'웹스터디 > php' 카테고리의 다른 글
무제한 멀티 업로드 -설명첨부 가능한 버전 (1) | 2008.05.23 |
---|---|
테이블 생성 (0) | 2008.05.21 |
php?변수명=변수값&변수명2=변수값2 ... (0) | 2008.05.21 |
자바스크립트 기초 (0) | 2008.05.21 |
MySQL 질의문 (0) | 2008.05.21 |
mysql 테이블복구(최적화)하기 (0) | 2008.05.21 |
php 로 디렉토리와 파일을 만들어 보자 (0) | 2008.05.21 |
PHP - TXT 파일 잃어서 웹에 뿌리자 (0) | 2008.05.21 |
웹 계정에서 지워지지 않는 폴더 및 파일 삭제하는 방법 (1) | 2008.04.05 |
평생쓰는 미니만년달력(배경버전) (0) | 2008.04.05 |
RECENT COMMENT