엑셀 코멘트 다운로드 질문드립니다. 채택완료
// 원글 + 코멘트 다운로드
$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>
답변에 대한 댓글 2개
이 곳 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개
날짜 구간 선택으로 넘어 온것 같은데 그 부분도 반영 될 수 있도록 했습니다..
오타가 있었네요...
댓글에서 여분필드 추가하고 작성된 댓글목록 파일다운 적용중이었습니다.
<?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>ㅊ
$search = " where wr_is_comment = 1 and wr_id = '{$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개
$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];
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
이렇게 하면 될 것입니다..