묻고답하기

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 남기남
구리구리 /tmp 소유주및 권한 설정..... 부탁 드립니다.  
찐빵 똑같은 ip가 계속 접속을... [3] 2007.08.10
Trezeguet 질문카테고리를 어떤걸로 골라야 할지 몰라서 웹디자인으로 질문합니다. [1] 2007.08.10
안상훈 현재 레이어의 위치(좌측 상단 좌표) 를 알 수 있는 스크립트는 없나요? [1] 2007.08.10
박진우 프레임위로 레이어 창이 뜨도록 하려면 ? [1] 2007.08.10
apraxas php 에서 그림 파일의 가로 세로 크기를 알 수 있나요? [2] 2007.08.10
김소영 php 파일 열경우마다 뜨는 말. Warning.. [1] 2007.08.10
Trezeguet 답변 부탁드립니다. 새창에 관한 질문입니다. [1] 2007.08.10
모르겠어요ㅠㅠ [2] 2007.08.10
이호한 [re] 질문 하나 다시 합니다.^^  
천성호 질문 하나 다시 합니다.^^  
사랑 플래쉬 답변 부탁드립니다.. 상세하게 설명좀... ㅡ,ㅜ [1] 2007.08.10
zyose 셀에 여백을 넣을때... [1] 2007.08.10
떵이리~ 레이어에 대해...  
이태운 페이지 스크롤 되있을때 새로고침하면 젤위로가는데.. 이 질문은. [1] 2007.08.10
새벽군 미디어 플레이어 6.4컨트롤에 대해... [1] 2007.08.10
배재선 nzeo.com 같은 레이아웃은 어떻게 만드나요? [1] 2007.08.10
완전초보 웹에 마우스를 대면 익스플로러 6에서는., [4] 2007.08.10
퓨어아이스 제 컴퓨터에서 폴더 열을때 자꾸 이상한 창이 떠요.  
rubin 방명록말인데요.  
허성 포토샵질문이요ㅠ_ㅠ [1] 2007.08.10
Free 이 싸이트에 있는 동영상 저장할수 없을까요?소스분석.. [1] 2007.08.10
carrot 제홈에 쓰인카운터소스인데여....2003년이 되면서 총카운터숫자가 줄어든거같아여...한2년넘은 홈인데 총카운터가1320으로 나와여..ㅡㅡ;;  
sjin21 태그관련 질문드립니다. [8] 2007.08.10
고영철 정말 죄송한데, 제로카운트 어디서 다운받아야 하나요? [1] 2007.08.10
허문정 계정관련 질문입니다. 많은 도움 부탁드립니다. [1] 2007.08.10
사랑 플래쉬 MX에서..... [1] 2007.08.10
사랑 플레쉬 영문 MX에서.... [1] 2007.08.10
눈물 자동 로그아웃 시간 설정에 관해서.. [4] 2007.08.10
꾸러기^^ 포토샵에서브러쉬가색칠이안되네요 ㅠ/ㅠ