엑셀 코멘트 다운로드 질문드립니다.

엑셀 코멘트 다운로드 질문드립니다.

QA

엑셀 코멘트 다운로드 질문드립니다.

본문

// 원글 + 코멘트 다운로드
$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} "));
$sql="select * from {$excel_down} {$search} order by wr_datetime desc";
$qry=sql_query($sql);

 

위 코드로 게시글을 엑셀로 받고 있습니다.

혹시 코멘트만 받도록 수정하려면 어떻게 해야할까요?

이 질문에 댓글 쓰기 :

답변 3

<?php
include_once "_common.php";

$bo_table = $_REQUEST['bo_table'];
$excel_down = $g5['write_prefix'] . $bo_table; //엑셀 다운로드 테이블
$wr_id = $_REQUEST['wr_id'];
$hp_filename = $bo_table."_".date('Y_md h_m');
$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );
header( "Content-Description: PHP4 Generated Data" );

//이 부분이 추가
$search = " where wr_is_comment = 1 and wr_parent = '{$wr_id}' ";

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} {$search} "));
$sql="select * from {$excel_down} {$search} order by wr_datetime desc";
$qry=sql_query($sql);
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {
    mso-style-parent:style0;
    mso-number-format:"\@";
    border:.5pt solid windowtext;
}
</style>
</head>

<body>
<table>
    <tr>
        <td class='txt'>이름</td>   
        <td class='txt'>추가1</td>
        <td class='txt'>추가2</td>
        <td class='txt'>추가3</td>
        <td class='txt'>추가4</td>
        <td class='txt'>추가5</td>
        <td class='txt'>추가6</td>
        <td class='txt'>추가7</td>
        <td class='txt'>추가8</td>
        <td class='txt'>추가9</td>
        <td class='txt'>내용</td> 
        <td class='txt'>작성일</td>
    </tr>

<?php
while($row=sql_fetch_array($qry)) {
    echo "
    <tr>
        <td class='txt'>{$row['wr_name']}</td> 
        <td class='txt'>{$row['wr_1']}</td>
        <td class='txt'>{$row['wr_2']}</td>
        <td class='txt'>{$row['wr_3']}</td>
        <td class='txt'>{$row['wr_4']}</td>
        <td class='txt'>{$row['wr_5']}</td>
        <td class='txt'>{$row['wr_6']}</td>
        <td class='txt'>{$row['wr_7']}</td>
        <td class='txt'>{$row['wr_8']}</td>
        <td class='txt'>{$row['wr_9']}</td>
        <td class='txt'>".get_text(strip_tags($row['wr_content']))."</td> 
        <td class='txt'>{$row['wr_datetime']}</td>
    </tr>
    ";
    $number--;
}
?>
</table>
</body>
</html>

$wr_id = $_REQUEST['wr_id'];
이 곳 wr_id가 적용이 안되나봅니다.

$search = " where wr_is_comment = 1 and wr_parent = '{$wr_id}' ";
이부분에서
$search = " where wr_is_comment = 1 and wr_parent = '1' ";
1로 바꾸니 1번 글은 잘 불러옵니다.

이것저것 대입해봐야겠습니다.

그리고 쪽지 확인바랍니다.
감사합니다.

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} where wr_is_comment = 1 "));
전체 댓글만 다운로드 하려면 이렇게 하면 됩니다.

 

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} where wr_is_comment = 1 and wr_id = '{$wr_id}' "));
해당 게시물의 댓글만 다운 받으려면 이렇게 하면 됩니다.

이렇게 했는데 원글도 같이 나오고 있습니다.

 

$bo_table = $_REQUEST['bo_table'];
$excel_down = $g5['write_prefix'] . $bo_table; //엑셀 다운로드 테이블
$wr_id = $_REQUEST['wr_id'];

$hp_filename = $bo_table."_".date('Y_md h_m');

$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );
header( "Content-Description: PHP4 Generated Data" );

$date1 = $_POST['date1']." 00:00:00";
$date2 = $_POST['date2']." 23:59:59";

$search = " where 1 ";
if ($_POST['date1'] && !$_POST['date2']) {
    $search = " and wr_datetime > '{$date1}' ";
} elseif (!$_POST['date1'] && $_POST['date2']) {
    $search = " and wr_datetime < '{$date2}' ";
} elseif ($_POST['date1'] && $_POST['date2']) {
    $search = " and wr_datetime > '{$date1}' && wr_datetime < '{$date2}' ";
}

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} where wr_is_comment = 1 and wr_id = '{$wr_id}' "));
$sql="select * from {$excel_down} {$search} order by wr_datetime desc";
$qry=sql_query($sql);

$number=$temp[0];


$bo_table = $_REQUEST['bo_table'];
$excel_down = $g5['write_prefix'] . $bo_table; //엑셀 다운로드 테이블
$wr_id = $_REQUEST['wr_id'];
$hp_filename = $bo_table."_".date('Y_md h_m');
$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );
header( "Content-Description: PHP4 Generated Data" );
$date1 = $_POST['date1']." 00:00:00";
$date2 = $_POST['date2']." 23:59:59";
//아래 부분은 날짜 기간 으로 검색 가능
$search = " where 1 ";
if ($_POST['date1'] && !$_POST['date2']) {
    $search = " and wr_datetime > '{$date1}' ";
} elseif (!$_POST['date1'] && $_POST['date2']) {
    $search = " and wr_datetime < '{$date2}' ";
} elseif ($_POST['date1'] && $_POST['date2']) {
    $search = " and wr_datetime > '{$date1}' && wr_datetime < '{$date2}' ";
}
//이 부분이 추가
$search .= " and wr_is_comment = 1 and wr_id = '{$wr_id}' ") ";

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} {$search} "));
$sql="select * from {$excel_down} {$search} order by wr_datetime desc";
$qry=sql_query($sql);
$number=$temp[0];

날짜는 다른분꺼 적용한거라 제외하고 적용한 파일 소스인데 댓글이 나오질 않습니다...
댓글에서 여분필드 추가하고 작성된 댓글목록 파일다운 적용중이었습니다.

<?php
include_once "_common.php";

$bo_table = $_REQUEST['bo_table'];
$excel_down = $g5['write_prefix'] . $bo_table; //엑셀 다운로드 테이블
$wr_id = $_REQUEST['wr_id'];
$hp_filename = $bo_table."_".date('Y_md h_m');
$g5['title'] = "엑셀 문서 다운로드";
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );
header( "Content-Description: PHP4 Generated Data" );

//이 부분이 추가
$search .= " and wr_is_comment = 1 and wr_id = '{$wr_id}' ";

$temp=sql_fetch_array(sql_query("select count(*) from {$excel_down} {$search} "));
$sql="select * from {$excel_down} {$search} order by wr_datetime desc";
$qry=sql_query($sql);
$number=$temp[0];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.txt {
    mso-style-parent:style0;
    mso-number-format:"\@";
    border:.5pt solid windowtext;
}
</style>
</head>

<body>
<table>
    <tr>
        <td class='txt'>이름</td>   
        <td class='txt'>추가1</td>
        <td class='txt'>추가2</td>
        <td class='txt'>추가3</td>
        <td class='txt'>추가4</td>
        <td class='txt'>추가5</td>
        <td class='txt'>추가6</td>
        <td class='txt'>추가7</td>
        <td class='txt'>추가8</td>
        <td class='txt'>추가9</td>
        <td class='txt'>내용</td> 
        <td class='txt'>작성일</td>
    </tr>

<?php
while($row=sql_fetch_array($qry)) {
    echo "
    <tr>
        <td class='txt'>{$row['wr_name']}</td> 
        <td class='txt'>{$row['wr_1']}</td>
        <td class='txt'>{$row['wr_2']}</td>
        <td class='txt'>{$row['wr_3']}</td>
        <td class='txt'>{$row['wr_4']}</td>
        <td class='txt'>{$row['wr_5']}</td>
        <td class='txt'>{$row['wr_6']}</td>
        <td class='txt'>{$row['wr_7']}</td>
        <td class='txt'>{$row['wr_8']}</td>
        <td class='txt'>{$row['wr_9']}</td>
        <td class='txt'>".get_text(strip_tags($row['wr_content']))."</td> 
        <td class='txt'>{$row['wr_datetime']}</td>
    </tr>
    ";
    $number--;
}
?>
</table>
</body>
</html>ㅊ

답변을 작성하시기 전에 로그인 해주세요.
전체 123,706
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT