코멘트 작성 글은 메인 최신글에 안나오게 하는 방법. 정보
코멘트 작성 글은 메인 최신글에 안나오게 하는 방법.본문
저는홈페이지 메인에 totalnew.php라는 파일로 최신글을 불러오고 있습니다.
두가지 문제가 있어 질문드립니다.
1. 코멘트 작성 글은 메인 최신글에 안나오게 하는 방법.
2. 코멘트 작성시 글내용 일부가 최신글로 나오게 하는방법.
아래 소스를 보시고 아시는분 꼭 알려 주시길 부탁합니다.
<?
include_once("./_common.php");
$sql_common = " from $g4[board_new_table] a, $g4[board_table] b, $g4[group_table] c
where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = '1' ";
if ($gr_id)
$sql_common .= " and b.gr_id = '$gr_id' ";
if ($view == "w")
$sql_common .= " and a.wr_id = a.wr_parent ";
else if ($view == "c")
$sql_common .= " and a.wr_id <> a.wr_parent ";
$sql_order = " order by a.bn_id desc ";
$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows = $config[cf_new_rows];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$group_select = "<select name=gr_id id=gr_id onchange='select_change();'><option value=''>전체그룹";
$sql = " select gr_id, gr_subject from $g4[group_table] order by gr_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$group_select .= "<option value='$row[gr_id]'>$row[gr_subject]";
}
$group_select .= "</select>";
$list = array();
$sql = " select a.*, b.bo_subject, c.gr_subject, c.gr_id
$sql_common
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$tmp_write_table = $g4[write_prefix] . $row[bo_table];
if ($row[wr_id] == $row[wr_parent]) // 원글
{
$comment = "";
$comment_link = "";
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$name = get_sideview($row2[mb_id], cut_str($row2[wr_name], $config[cf_cut_name]), $row2[wr_email], $row2[wr_homepage]);
// 당일인 경우 시간으로 표시함
$datetime = substr($row2[wr_datetime],0,10);
$datetime2 = $row2[wr_datetime];
if ($datetime == $g4[time_ymd])
$datetime2 = substr($datetime2,11,5);
else
$datetime2 = substr($datetime2,5,5);
}
else // 코멘트
{
$comment = "[코] ";
$comment_link = "#c_{$row[wr_id]}";
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_parent]' ");
$row3 = sql_fetch(" select mb_id, wr_name, wr_email, wr_homepage, wr_datetime from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$list[$i][mb_id] = $row3[mb_id];
$list[$i][wr_name] = $row3[wr_name];
$list[$i][wr_email] = $row3[wr_email];
$list[$i][wr_homepage] = $row3[wr_homepage];
$name = get_sideview($row3[mb_id], cut_str($row3[wr_name], $config[cf_cut_name]), $row3[wr_email], $row3[wr_homepage]);
// 당일인 경우 시간으로 표시함
$datetime = substr($row3[wr_datetime],0,10);
$datetime2 = $row3[wr_datetime];
if ($datetime == $g4[time_ymd])
$datetime2 = substr($datetime2,11,5);
else
$datetime2 = substr($datetime2,5,5);
}
$list[$i][gr_id] = $row[gr_id];
$list[$i][bo_table] = $row[bo_table];
$list[$i][name] = $name;
$list[$i][comment] = $comment;
$list[$i][href] = "$g4[bbs]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]{$comment_link}";
$list[$i][datetime] = $datetime;
$list[$i][datetime2] = $datetime2;
$list[$i][gr_subject] = $row[gr_subject];
$list[$i][bo_subject] = $row[bo_subject];
$list[$i][wr_subject] = $row2[wr_subject];
}
$write_pages = get_paging($config[cf_write_pages], $page, $total_page, "?gr_id=$gr_id&view=$view&page=");
$new_themes_path = "$g4[path]/themes/new/$config[cf_new_themes]";
echo "<script language=\"javascript\" src=\"$g4[path]/js/sideview.js\"></script>\n";
?>
<style>
.n_title1 { font-family:돋움; font-size:9pt; color:#fff; }
.n_title2 { font-family:돋움; font-size:9pt; color:#CCCCCC; }
</style>
<!-- 제목 시작 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2" height="30" bgcolor="#EDEDED" align="bottom">
<a href='./bbs/new.php'><b>최근게시물</b></a>
<script>
now= new Date;
dayName = new Array ("일요일","월요일","화요일","수요일","목요일","금요일","토요일");
document.write (now.getFullYear() + '-' + eval(now.getMonth()+1) + '-' + now.getDate() + ' ' + dayName[now.getDay()]);
</script>
</td>
</tr>
<td bgcolor=white>
<table width="100%" cellspacing="0" bordercolordark="white" bordercolorlight="black" cellpadding="0" style="border-width:1; border-color:rgb(237,235,235); border-style:solid;">
<?
for ($i=0; $i<count($list); $i++)
{
$gr_subject = cut_str($list[$i][gr_subject], 10);
$bo_subject = cut_str($list[$i][bo_subject], 10);
$wr_subject = get_text(cut_str($list[$i][wr_subject], 55));
echo <<<HEREDOC
<tr>
<td height="25"> <a href='{$list[$i][href]}'><font color=#ff9900>[{$bo_subject}]</font> {$list[$i][comment]}{$wr_subject}</a></td>
<td height="25"><a href='{$list[$i][href]}'><p align="right" style="margin-right:3mm;"><font color="#CCCCCC">{$list[$i][datetime]}</font></a></td>
</tr>
<tr>
<td colspan="9" height="1" background="{$new_themes_path}/img/dot_bg.gif"></td>
</tr>
HEREDOC;
}
?>
<? if ($i == 0) { ?>
<tr><td align=center><font color="#CCCCCC">게시물이 없습니다.</font></td>
</tr>
<? } ?>
</table>
</table>
두가지 문제가 있어 질문드립니다.
1. 코멘트 작성 글은 메인 최신글에 안나오게 하는 방법.
2. 코멘트 작성시 글내용 일부가 최신글로 나오게 하는방법.
아래 소스를 보시고 아시는분 꼭 알려 주시길 부탁합니다.
<?
include_once("./_common.php");
$sql_common = " from $g4[board_new_table] a, $g4[board_table] b, $g4[group_table] c
where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = '1' ";
if ($gr_id)
$sql_common .= " and b.gr_id = '$gr_id' ";
if ($view == "w")
$sql_common .= " and a.wr_id = a.wr_parent ";
else if ($view == "c")
$sql_common .= " and a.wr_id <> a.wr_parent ";
$sql_order = " order by a.bn_id desc ";
$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows = $config[cf_new_rows];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$group_select = "<select name=gr_id id=gr_id onchange='select_change();'><option value=''>전체그룹";
$sql = " select gr_id, gr_subject from $g4[group_table] order by gr_id ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$group_select .= "<option value='$row[gr_id]'>$row[gr_subject]";
}
$group_select .= "</select>";
$list = array();
$sql = " select a.*, b.bo_subject, c.gr_subject, c.gr_id
$sql_common
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$tmp_write_table = $g4[write_prefix] . $row[bo_table];
if ($row[wr_id] == $row[wr_parent]) // 원글
{
$comment = "";
$comment_link = "";
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$name = get_sideview($row2[mb_id], cut_str($row2[wr_name], $config[cf_cut_name]), $row2[wr_email], $row2[wr_homepage]);
// 당일인 경우 시간으로 표시함
$datetime = substr($row2[wr_datetime],0,10);
$datetime2 = $row2[wr_datetime];
if ($datetime == $g4[time_ymd])
$datetime2 = substr($datetime2,11,5);
else
$datetime2 = substr($datetime2,5,5);
}
else // 코멘트
{
$comment = "[코] ";
$comment_link = "#c_{$row[wr_id]}";
$row2 = sql_fetch(" select * from $tmp_write_table where wr_id = '$row[wr_parent]' ");
$row3 = sql_fetch(" select mb_id, wr_name, wr_email, wr_homepage, wr_datetime from $tmp_write_table where wr_id = '$row[wr_id]' ");
$list[$i] = $row2;
$list[$i][mb_id] = $row3[mb_id];
$list[$i][wr_name] = $row3[wr_name];
$list[$i][wr_email] = $row3[wr_email];
$list[$i][wr_homepage] = $row3[wr_homepage];
$name = get_sideview($row3[mb_id], cut_str($row3[wr_name], $config[cf_cut_name]), $row3[wr_email], $row3[wr_homepage]);
// 당일인 경우 시간으로 표시함
$datetime = substr($row3[wr_datetime],0,10);
$datetime2 = $row3[wr_datetime];
if ($datetime == $g4[time_ymd])
$datetime2 = substr($datetime2,11,5);
else
$datetime2 = substr($datetime2,5,5);
}
$list[$i][gr_id] = $row[gr_id];
$list[$i][bo_table] = $row[bo_table];
$list[$i][name] = $name;
$list[$i][comment] = $comment;
$list[$i][href] = "$g4[bbs]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]{$comment_link}";
$list[$i][datetime] = $datetime;
$list[$i][datetime2] = $datetime2;
$list[$i][gr_subject] = $row[gr_subject];
$list[$i][bo_subject] = $row[bo_subject];
$list[$i][wr_subject] = $row2[wr_subject];
}
$write_pages = get_paging($config[cf_write_pages], $page, $total_page, "?gr_id=$gr_id&view=$view&page=");
$new_themes_path = "$g4[path]/themes/new/$config[cf_new_themes]";
echo "<script language=\"javascript\" src=\"$g4[path]/js/sideview.js\"></script>\n";
?>
<style>
.n_title1 { font-family:돋움; font-size:9pt; color:#fff; }
.n_title2 { font-family:돋움; font-size:9pt; color:#CCCCCC; }
</style>
<!-- 제목 시작 -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2" height="30" bgcolor="#EDEDED" align="bottom">
<a href='./bbs/new.php'><b>최근게시물</b></a>
<script>
now= new Date;
dayName = new Array ("일요일","월요일","화요일","수요일","목요일","금요일","토요일");
document.write (now.getFullYear() + '-' + eval(now.getMonth()+1) + '-' + now.getDate() + ' ' + dayName[now.getDay()]);
</script>
</td>
</tr>
<td bgcolor=white>
<table width="100%" cellspacing="0" bordercolordark="white" bordercolorlight="black" cellpadding="0" style="border-width:1; border-color:rgb(237,235,235); border-style:solid;">
<?
for ($i=0; $i<count($list); $i++)
{
$gr_subject = cut_str($list[$i][gr_subject], 10);
$bo_subject = cut_str($list[$i][bo_subject], 10);
$wr_subject = get_text(cut_str($list[$i][wr_subject], 55));
echo <<<HEREDOC
<tr>
<td height="25"> <a href='{$list[$i][href]}'><font color=#ff9900>[{$bo_subject}]</font> {$list[$i][comment]}{$wr_subject}</a></td>
<td height="25"><a href='{$list[$i][href]}'><p align="right" style="margin-right:3mm;"><font color="#CCCCCC">{$list[$i][datetime]}</font></a></td>
</tr>
<tr>
<td colspan="9" height="1" background="{$new_themes_path}/img/dot_bg.gif"></td>
</tr>
HEREDOC;
}
?>
<? if ($i == 0) { ?>
<tr><td align=center><font color="#CCCCCC">게시물이 없습니다.</font></td>
</tr>
<? } ?>
</table>
</table>
댓글 전체