묻고답하기

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 남기남
밀가루 사이트 메뉴 편집에서 메뉴추가가 되지 않아요... [4] 2015.09.01 by 밀가루
rhqemddl77 index.php는 어떻게 다운하나요? [2] 2015.09.01 by Double'U'
hpsong 권한이 없습니다..... file  
가르송 도메인주소를 바꿨는데요 ㅠㅠ [3] 2015.09.01 by sejin7940
내똥굴따 scm music player 문제점 도움 앙망합니다. file  
hellojdy 중고마켓모듈 모바일 [8] 2015.08.31 by jake
삼학도 도와주세요~~회원가입폼 수정질문 [1] 2015.08.31 by 닉이
매실696e5 특정게시판에만 확장변수로제목설정하기 [1] 2015.08.31 by 닉이
삼학도 회원가입폼 수정을할려는데 어디에 있나요~ [1] file 2015.08.31 by 로이조52
초록불 ftp 접속 오류 어떻게 하나요? [3] file 2015.08.31 by 초록불
다롱이397b7 게시판 상세보기 화면에서 등록 날짜 부분을 삭제하고 싶습니다. [2] file 2015.08.31 by 다롱이397b7
별종외계오동 mysql DB를 사이트이전하면서 mariadb로 바꿨습니다. [1] 2015.08.31 by 기진곰
오늘은삽질왕 core 업그레이드를 했는데 사이트 접속이 거부되었습니다. 1.7.11 -> 1.8.8 [4] 2015.08.31 by 오늘은삽질왕
홍길동친구 회원이 작성한 작성글수와 댓글 수를 확인하는 방법이 있나요? [2] 2015.08.31 by 홍길동친구
항우 메인에 최신게시글 추출 및 외부로그인 되지 않습니다. [3] 2015.08.31 by 한꼬마
c2**** js파일은 어떻게 얻나요? [4] 2015.08.31 by purecity
빙짱 레이아웃이 다른 두 사이트에서 하나의 게시판을 이용하는 방법 [2] 2015.08.31 by 이온디
이주연743 웹사이트에 있는 바이러스 치료 [4] 2015.08.31 by YJSoft
steve xe core 1.7버전을 사용중인데 최신버전으로 업데이트가 안되네요. [1] 2015.08.31 by 기진곰
센쇼 [질문] 막 입문했습니다만, 컨텐츠 생성이 안됩니다. (게시판, 문서) [3] file 2015.08.31 by 센쇼