묻고답하기

엑셀파일로 변환한 후에도 콤마(,) 표시도 나타나고

콤마 뒷부분도 잘리지 않고 보이게 하려면 어떻게 해야 할지요?

str_replace 함수나 다른 방법이 혹시 있을까요?

 

게시판 내용의 엑셀파일 변환부분은 DB불러 오는 부분 제외하고 다음과 같은 형식이거든요..

$getFields = array("title","regdate","content"); //출력원하는 칼럼을 배열로 입력

 

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>";    

 

$date = DateTime::createFromFormat("YmdHis",$val);

echo "<td>".htmlspecialchars($date->format('Y-m-d H:i:s'))."</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;

        }

 

    }

                $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");  

                    $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]=="contact"){  

                                echo str_replace("|@|","-",htmlspecialchars($extra_arr[1]));

}

                                elseif($extra_title[eid]=="date"){

$date = DateTime::createFromFormat("Ymd",$extra_arr[1]);

echo htmlspecialchars($date->format('Y-m-d'));

}

                            //기타 배열값들은 ',' 로 변경

                            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>";   

                }              

                /////////////////////////////////////////////////////////////////////

 

    echo"</tr>";

}

 

 

 

태그 연관 글
  1. [2016/12/30] 묻고답하기 회원 포인트를 엑셀로 받을 수 있나요? by 권만주 *2
  2. [2014/08/12] 묻고답하기 sql 에서 게시판 글 데이터를 엑셀화해서 한번에 올리려고합니다. by 모몽
  3. [2010/08/04] 묻고답하기 제로보드 게시판과 회원정보 변환방법 문의 드립니다. by 형명길
글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
rail_man 제목을 '나눔고딕'으로 바꾸고자 합니다. [2] file 2018.01.24 by rail_man
종합예술인 모바일페이지 화면짤림 현상 질문드립니다. [2] file 2018.01.24 by 종합예술인
쮸야282 10여년 홈담고 있던 호스팅을 옮기려 하는데, 혹시 옮기면 따로 해줘야 할게 있습니까? [1] 2018.01.24 by 디자인클립
시움 회원가입할때 이상한 창이 [2] file 2018.01.24 by 시움
killenemy 엑셀로 된 자료를 게시판에 업로드하는 방법은 없을까요? [1] 2018.01.24 by 디자인클립
DY 크롬에서 글 등록 버튼을 눌러도 아무 반응이 없네요 ㅠ file  
y**** SSL 인증서 없이 https 통신하는 법? [1] 2018.01.24 by 기진곰
신라면 콘텐츠 문의입니다. [5] 2018.01.23 by 코코넛
x**** 404 에러  
기러기오빠 해당 오류의 뜻이 무엇인가요? [1] 2018.01.23 by sejin7940
sky**** 관리 메뉴에서 welcome_page 의 수정을 어디서 하는지요? [1] 2018.01.22 by 기러기오빠
제이오 사이트메뉴편집이 안보이고 글쓰기가 안됩니다. 도와주세욤 [1] 2018.01.22 by ezup2
신라면 홈페이지 제작 문의입니다.  
허접 네이버아이디 회원가입 위젯에서 이메일 주소 확인 창의 오픈 유무의 차이가 궁금합니다 file  
putty XE 사이트메뉴 편집에서 "모듈이 존재하지 않음" 이라고 나오면서 수정이 안되요 [1] file 2018.01.22 by sky****
Kxo 멘붕옵니다... 페이지관리에서 welcome 페이지 수정한 뒤로 [2] file 2018.01.22 by sky****
killenemy 윈도우 모바일에서 제로보드 XE를 사용할 수는 없나요?  
sky**** 모바일 게시판 하단에 밴드 공유 버튼을 넣으려고 합니다. [2] 2018.01.22 by sky****
hyama 무료 도메인에 관련해서 물어봅니다. [6] 2018.01.22 by hyama
rail_man XE 업데이트 후 에디트플러스에서 오류가 납니다. [1] file 2018.01.22 by 디자인클립
네모세상 쿡래빗 레이아웃 사이트맵 배경색 변경 file  
패닉 xe 설치 오류 [1] 2018.01.21 by sejin7940
카이4525b 게시물 주소 복사 기능 관련 문의입니다. [2] 2018.01.21 by 카이4525b
셍셍 대시보드 로그인을 누르면 홈으로 이동해요 ㅠㅠ [1] 2018.01.21 by 휘즈
rail_man 도메인을 관리자 페이지 일반 설정에서 변경 후 접속하니 오류가 발생합니다. [1] 2018.01.21 by 휘즈
울댕댕 홈페이지 에러ㅠㅠㅠ file  
알랭 글상자/인용구 에디터 컴포넌트가 아예 작동이 안되는데요  
시크릿_이루어진다 커뮤니티 사이트 만들려고하는데요. [3] 2018.01.19 by 2donggalbi
pinta 홈페이지 제목이 한자 (한문) 로 표기됩니다 ㅜㅜ 도와주세요 (사진 有) [1] file 2018.01.19 by 2donggalbi
쮸야282 네이버 사이트 검색이 얼마전부터 안되네요. 혹시 아시는분 계신지요? [6] file 2018.01.19 by 쮸야282