테스트 사이트 - 개발 중인 베타 버전입니다

엑셀 코멘트 다운로드 질문드립니다. 채택완료

자우림 1년 전 조회 1,765

// 원글 + 코멘트 다운로드
$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개

채택된 답변
+20 포인트

<?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>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

설국열차
1년 전
착오가 있었네요..
이렇게 하면 될 것입니다..
자우림
1년 전
$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번 글은 잘 불러옵니다.

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

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

댓글을 작성하려면 로그인이 필요합니다.

</p>

<p>$bo_table = $_REQUEST['bo_table'];

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

$wr_id = $_REQUEST['wr_id'];</p>

<p>$hp_filename = $bo_table."_".date('Y_md h_m');</p>

<p>$g5['title'] = "엑셀 문서 다운로드";

header( "Content-type: application/vnd.ms-excel" );

header( "Content-Disposition: attachment; filename={$hp_filename}.xls" );

header( "Content-Description: PHP4 Generated Data" );</p>

<p>$date1 = $_POST['date1']." 00:00:00";

$date2 = $_POST['date2']." 23:59:59";</p>

<p>//아래 부분은 날짜 기간 으로 검색 가능

$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}' ";

}</p>

<p>//이 부분이 추가

$search .= " and wr_is_comment = 1 and wr_id = '{$wr_id}' ") ";</p>

<p>

$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);</p>

<p>$number=$temp[0];</p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 5개

설국열차
1년 전
이렇게 하면 해당 게시물의 해당 댓글만 다운 될 것입니다.
날짜 구간 선택으로 넘어 온것 같은데 그 부분도 반영 될 수 있도록 했습니다..
설국열차
1년 전
$search .= " and wr_is_comment = 1 and wr_id = '{$wr_id}' ";
오타가 있었네요...
자우림
1년 전
날짜는 다른분꺼 적용한거라 제외하고 적용한 파일 소스인데 댓글이 나오질 않습니다...
댓글에서 여분필드 추가하고 작성된 댓글목록 파일다운 적용중이었습니다.

<?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>ㅊ
설국열차
1년 전
//이 부분이 추가
$search = " where wr_is_comment = 1 and wr_id = '{$wr_id}' ";

이렇게 수정 하세요
설국열차
1년 전
$wr_id 는 실제 게시물 번호로 넘겨야 합니다.
댓글에 해당 하는 wr_id 이면 나오는 것이 하나도 없습니다.

댓글을 작성하려면 로그인이 필요합니다.

$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}' "));
해당 게시물의 댓글만 다운 받으려면 이렇게 하면 됩니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

자우림
1년 전
이렇게 했는데 원글도 같이 나오고 있습니다.



$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];

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인