묻고답하기

https://www.xpressengine.com/tip/22795784

한이73님의 팁을 바탕으로 게시글 엑셀 추출하기에 시도했지만.. ㅠㅠ


엑셀 다운 받으면..

추출화면에서 아래와 같이 나오고 끝입니다. ㅠㅠ


titlecontentnick_nameregdate



무엇이 문제일까요? ㅠㅠ

(모듈 이름 buy의 번호=1 인 게시판의 글을 엑셀로 추출하려고 합니다.)

q.jpg


--------------------------------------------------------------


<?php
//url 로 직접 불러오는것을 방지
if(!strstr($_SERVER['HTTP_REFERER'],$_SERVER['SERVER_NAME'])&& !strstr($_SERVER['HTTP_REFERER'],'out_excel.php')) exit;
 
$info = array(
"host" => "localhost",
"user" => "--------",
"pass" => "-------",
"db" => "---------",
"table" => "xe_documents",
"module_srl" => "1",
);

$getFields = array("title","content","nick_name","regdate"); //출력원하는 칼럼을 배열로 입력
 
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=doc_".date('Ymd').".xls");
 
$con = mysql_connect($info[host], $info[user], $info[pass]) || die(mysql_error());
mysql_query("set names utf8");
$con_db = mysql_select_db($info[db]) || die(mysql_error());
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=Content-Type content=text/html; charset="utf-8">
</head>
<body>
<table border=1>
<tr align=center>
 
<?php
//제목 불러오기
$fields = mysql_list_fields("$info[db]", "$info[table]");
$columns = mysql_num_fields($fields);
 
for( $i=0 ; $i<$columns ; $i++ )
{
    $field[$i]=mysql_field_name($fields, $i);
    if( in_array($field[$i], $getFields) ) echo "<th>".$field[$i]."</th>";
}
 
//확장변수의 타이틀은 값이므로       
$result = mysql_query("select  var_name from xe_document_extra_keys where module_srl = $info[module_srl]");                  
while( $data = mysql_fetch_array($result) )
{                          
    echo "<th>".htmlspecialchars($data[var_name])."</th>";
}  
 
echo"</tr>";             
 
 
//데이터 불러오기
$result = mysql_query("select * from $info[table] where module_srl = $info[module_srl]");
while( $data = mysql_fetch_assoc($result) )
{
    echo"<tr>";
    foreach( $data as $key => $val )
    {
        if( in_array($key, $getFields) )
        {
            if ($key ==  'regdate') { 
                echo "<td   style='mso-number-format:\"0_ \";' >".htmlspecialchars($val)."</td>";               
            }elseif ($key ==  'content'){       //내용 출력할경우 태그가 그대로 출력됨         
                //echo "<td>".$val."</td>";     //셀이 두칸이상으로 늘어남
                echo "<td >".htmlspecialchars(strip_tags(str_replace(" ","",$val)))."</td>";
            }else {
                echo "<td>".htmlspecialchars($val)."</td>";
            }  
        }
 
        if ($key ==  'document_srl'){           //확장변수 불러올때 사용
            $d_srl=$val;
        }
 
    }
                //확장변수 출력 ////////////////////////////////////////////
                //eid리스트를 불러온다
                $query=mysql_query("select eid from xe_document_extra_keys where module_srl = $info[module_srl]");      
                while($extra_title=mysql_fetch_array($query))
                {      
                    echo"<td>";
 
                    $egetFields = array("value","eid");  
                    //확장변수 값을 불러와 eid값이 같은곳에 출력
                    $extra_result = mysql_query("select * from xe_document_extra_vars where document_srl = $d_srl"); 
                    while( $edata = mysql_fetch_assoc($extra_result) )
                    {
                        $extra_str="";
                        foreach( $edata as $key => $val ){
                            if( in_array($key, $egetFields) ){                          
                                $extra_str = $val.",".$extra_str;
                            }
                        }
 
                        $extra_arr=explode(",",$extra_str);                                
                        if ($extra_title[eid]==$extra_arr[0]){
 
                            //전화번호값은 "|@|" 를 "-" 로 변경
                            if($extra_title[eid]=="mb_phone_Number"){
                                echo str_replace("|@|","-",htmlspecialchars($extra_arr[1]));
 
                            //기타 배열값들은 ',' 로 변경
                            }elseif($extra_title[eid]=="mb_incomplete"||$extra_title[eid]=="mb_cs"){
                                echo str_replace("|@|",",",htmlspecialchars($extra_arr[1]));
                            }else{
                                echo htmlspecialchars($extra_arr[1]);                     
                            }
                        }
                    }
 
                    echo"</td>";   //eid값이 없으면 빈칸입력
                }              
                /////////////////////////////////////////////////////////////////////
 
    echo"</tr>";
}
 
 
?>
</table>
</body>
</html>

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
rice_solar 일정한 글자수 이상 되는 댓글에만 포인트 주는 방법 [1] 2015.01.22 by 몽실아빠
Centell 치명적인 문제로 해결이 안 되서 DB만 남기고 재설치를 하고 싶습니다. [2] 2015.01.22 by Centell
엑스이이와이 신디케이션모듈의...fail log를 삭제하려면...  
이지가이드 메뉴간 이동이 원할하지 않아서 질문드려요? [2] 2015.01.22 by 이지가이드
newi 인증메일이 안옵니다.  
putty 다국어 기능 사용시 게시판 사용 방법을 잘 모르겠네요 [2] 2015.01.22 by putty
비틀즈 제로보드 1.5.3.3 페이지 오류 file  
TakeUrban 위젯 설정에서 새창 띄우기  
허허길드짱 고수님들께 문의드립니다~ 이미지와 파일첨부 분류시키려면.. [2] 2015.01.22 by 허허길드짱
근성캐 게시판 생성이 안 되는데... ㅠ [2] file 2015.01.22 by 근성캐
페르난도_알론소 html/css 설정에서 layout.css 쓰기 질문입니다. [6] file 2015.01.22 by 페르난도_알론소
류망스 게시물 엑셀 추출 질문 입니다. [2] file 2015.01.22 by 류망스
세상의모든계산기 위젯 로딩중 멈춤 -> 홈페이지 전체 로딩 멈춤 : 가능한 증상인가요? file  
leeadra html파일끼리 파라미터값 주고받는 과정 질문이요... [1] 2015.01.22 by hhgyu
4231 db중에 log기록을 수동으로 삭제하고싶습니다. [2] 2015.01.22 by 세상의모든계산기
뮤르시엘라고 업데이트 후 html코드등을 잘못쓰면 먹통이 되어버립니다 [7] 2015.01.22 by 뮤르시엘라고
플러스투 ftp에는 있는데 '설치된 모듈' 리스트에서는 모듈을 클릭할 수가 없습니다 [1] 2015.01.22 by 세상의모든계산기
상큼하게 국내외 믿을 수 있는 디도스존이 있나요?  
아포파스 ssl 적용후에도 기본페이지(로그인)이 http로 열립니다. [2] 2015.01.22 by 아포파스
두루미다 도와주세요..인증모듈관련 [2] 2015.01.22 by 두루미다
leeadra [급함]웹 서버 운영 중 문제발생 [1] 2015.01.22 by GG
중년- 간단한 html이 안먹히네요. [4] 2015.01.22 by 중년-
GREATGUY 검색어 통계모듈 질문드립니다. file  
꾸링 신디케이션 SEO? 사이트맵 충돌? [4] file 2015.01.22 by Migguragi
광우 안녕하세요. 어드민 로그인 해결좀.. [2] file 2015.01.22 by 광우
ssari.myid.net XE Contact Us alert창 수정 file  
bb 게시판의 제목이나 날짜를 다른단어로 출력하기 [1] file 2015.01.22 by ssari.myid.net
아진검 xe 설치시 files 775 퍼미션  
xe초보자 소규모 사이트 운영중입니다  
csad 소셜xe잘못된 요청입니다는 어떻게 하죠? file