코멘트, 원글 제목 나오기 정보
코멘트, 원글 제목 나오기본문
오류 주소 :www.jayu.or.kr
메인페이지 좌측상단에 최근게시물이 게시되고 있는데요, 얼마전 이곳의 도움으로 코멘트까지 연동이 되었네요, 그런데 코멘트가 연동될 때,코멘트의 내용이 아니라 원글의 제목이 떴으면 좋겠다는 생각으로 도움을 청합니다. 꼭 좀 도와주세요.참고로 my_new.php소스올립니다.
<?php
function get_new2($rowCnt, $maxStr)
{
global $g4, $gr_id, $config;
$maxRow = 100;
$exc = "('f_bbs','f_pic','f_vod')";
$s = "
select
a.*, b.bo_subject, c.gr_subject, c.gr_id
from
$g4[board_new_table] a,
$g4[board_table] b,
$g4[group_table] c
where
a.bo_table = b.bo_table
and b.bo_table not in {$exc}
and b.gr_id = c.gr_id
and b.bo_use_search = '1'
order by a.bn_id desc
limit $maxRow
";
$i = 0;
$res = mysql_query($s);
while ($row = mysql_fetch_array($res))
{
if ($i >= $rowCnt) break;
$s = "
select wr_id,wr_is_comment, wr_subject,wr_content, wr_comment, wr_datetime, wr_name
from $g4[write_prefix]$row[bo_table]
where wr_id = '$row[wr_id]'
";
$list[$i] = mysql_fetch_array(mysql_query($s));
$list[$i][commentCnt] = $list[$i][wr_comment];
$list[$i][bo_subject] = $row[bo_subject];
if($list[$i][wr_is_comment] == "1"){
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
}else{
$list[$i][subject] = cut_str(get_text($list[$i][wr_subject]), $maxStr);
}
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id={$list[$i][wr_id]}";
$list[$i][title] = addslashes(get_text($list[$i][wr_subject])." / ".$list[$i][wr_datetime]);
$list[$i][title] = addslashes(get_text($list[$i][wr_subject])." / ".$list[$i][wr_datetime]);
$list[$i]['icon_new'] = "";
if ($list[$i][wr_datetime] >= date("Y-m-d H:i ", $g4['server_time'] - (1 * 24 * 3600))){ // 3은 날짜
$list[$i][icon_new] = "<img src='$g4[path]/skin/latest/basic/img/icon_new.gif' align='absmiddle'>";}
$i++;
}
return $list;
}
function my_new2($rowCnt = 10, $maxStr = 20, $maxWidth = "100%") { global $g4; $list = get_new2($rowCnt, $maxStr); ?>
<table width="95%" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
</table></td>
</tr>
<?php $n = count($list); for ($i = 0; $i < $n; $i++) { ?>
<tr>
<td colspan="4"><table width="95%">
<tr>
<td height="19"><nobr style='display:block; overflow:hidden; width:210;'> <span style="font-weight:normal;">
<a href="<?php echo $list[$i][href]; ?>" title="<?php echo $list[$i][title]; ?>"> [<?php echo $list[$i][wr_name]; ?>]
<?=$list[$i][icon_new]?> <?php echo $list[$i][subject]; ?>
<?php if ($list[$i][commentCnt]) { ?>
<font color="tomato">(<?php echo $list[$i][commentCnt]; ?>)</font>
<?php } ?>
<br>
<?=$list[$i][datetime]?>
</span> </a> </nobr> </td>
</tr>
</table></td>
</tr>
<?php } ?>
</table>
<?php } ?>
메인페이지 좌측상단에 최근게시물이 게시되고 있는데요, 얼마전 이곳의 도움으로 코멘트까지 연동이 되었네요, 그런데 코멘트가 연동될 때,코멘트의 내용이 아니라 원글의 제목이 떴으면 좋겠다는 생각으로 도움을 청합니다. 꼭 좀 도와주세요.참고로 my_new.php소스올립니다.
<?php
function get_new2($rowCnt, $maxStr)
{
global $g4, $gr_id, $config;
$maxRow = 100;
$exc = "('f_bbs','f_pic','f_vod')";
$s = "
select
a.*, b.bo_subject, c.gr_subject, c.gr_id
from
$g4[board_new_table] a,
$g4[board_table] b,
$g4[group_table] c
where
a.bo_table = b.bo_table
and b.bo_table not in {$exc}
and b.gr_id = c.gr_id
and b.bo_use_search = '1'
order by a.bn_id desc
limit $maxRow
";
$i = 0;
$res = mysql_query($s);
while ($row = mysql_fetch_array($res))
{
if ($i >= $rowCnt) break;
$s = "
select wr_id,wr_is_comment, wr_subject,wr_content, wr_comment, wr_datetime, wr_name
from $g4[write_prefix]$row[bo_table]
where wr_id = '$row[wr_id]'
";
$list[$i] = mysql_fetch_array(mysql_query($s));
$list[$i][commentCnt] = $list[$i][wr_comment];
$list[$i][bo_subject] = $row[bo_subject];
if($list[$i][wr_is_comment] == "1"){
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
}else{
$list[$i][subject] = cut_str(get_text($list[$i][wr_subject]), $maxStr);
}
$list[$i][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id={$list[$i][wr_id]}";
$list[$i][title] = addslashes(get_text($list[$i][wr_subject])." / ".$list[$i][wr_datetime]);
$list[$i][title] = addslashes(get_text($list[$i][wr_subject])." / ".$list[$i][wr_datetime]);
$list[$i]['icon_new'] = "";
if ($list[$i][wr_datetime] >= date("Y-m-d H:i ", $g4['server_time'] - (1 * 24 * 3600))){ // 3은 날짜
$list[$i][icon_new] = "<img src='$g4[path]/skin/latest/basic/img/icon_new.gif' align='absmiddle'>";}
$i++;
}
return $list;
}
function my_new2($rowCnt = 10, $maxStr = 20, $maxWidth = "100%") { global $g4; $list = get_new2($rowCnt, $maxStr); ?>
<table width="95%" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
</table></td>
</tr>
<?php $n = count($list); for ($i = 0; $i < $n; $i++) { ?>
<tr>
<td colspan="4"><table width="95%">
<tr>
<td height="19"><nobr style='display:block; overflow:hidden; width:210;'> <span style="font-weight:normal;">
<a href="<?php echo $list[$i][href]; ?>" title="<?php echo $list[$i][title]; ?>"> [<?php echo $list[$i][wr_name]; ?>]
<?=$list[$i][icon_new]?> <?php echo $list[$i][subject]; ?>
<?php if ($list[$i][commentCnt]) { ?>
<font color="tomato">(<?php echo $list[$i][commentCnt]; ?>)</font>
<?php } ?>
<br>
<?=$list[$i][datetime]?>
</span> </a> </nobr> </td>
</tr>
</table></td>
</tr>
<?php } ?>
</table>
<?php } ?>
댓글 전체

if($list[$i][wr_is_comment] == "1"){
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
}else{
요부분에서
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
대신
$par = sql_fetch("select wr_subject from $g4[write_prefix]$row[bo_table] where wr_id = '{$list[$i][wr_parent]}'");
$list[$i][subject] = cut_str(get_text($par[wr_subject]), $maxStr);
하시면 원글 제목이 나옵니다.
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
}else{
요부분에서
$list[$i][subject] = cut_str(get_text($list[$i][wr_content]), $maxStr);
대신
$par = sql_fetch("select wr_subject from $g4[write_prefix]$row[bo_table] where wr_id = '{$list[$i][wr_parent]}'");
$list[$i][subject] = cut_str(get_text($par[wr_subject]), $maxStr);
하시면 원글 제목이 나옵니다.