최신글에서 코멘트가 없으면 안나오게 할수 잇는지요? 정보
최신글에서 코멘트가 없으면 안나오게 할수 잇는지요?
본문
안녕하세요. 아래 소스로 출력을 하다보니 코멘트가 없어도 "[0]" 이렇게 나오는데요.....
코멘트가 없을때 그냥 [0]자체가 안나오게 가능한지요.
물론 코멘트가 있으면 정상적으로 출력하구요.
답변 부탁을 드립니다. 감사합니다.
<?
include_once("./_common.php");
define("_CO_INDEX_", TRUE);
$html_title = "더쿠페";
$g4[title] = "" . $html_title;
include_once("./_head.php");
$before_day = 9; //게시물을 추출할기간설정
$before_time = date("Y-m-d H:i:s", $g4[server_time] - (86400 * $before_day));
$list1 = array();
$top1 = 5;
$bo_tables = "('gallery','clubgallery')"; // <-- board1~3은 원하는 게시판의 bo_table 값들
$sql = " select bo_table, bo_notice from $g4[board_table]
where bo_table in $bo_tables";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
$sql2 = " select * from $g4[write_prefix]$row[bo_table]
where wr_comment > -1
and wr_datetime >= '$before_time' ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2))
{
$key = substr('00000'.$row2[wr_comment],-5) . '-' . $row2[wr_id];
$list1[$key][subject] = conv_subject($row2[wr_subject],22,'…');
$list1[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list1[$key][bo_table] = $row[bo_table];
$list1[$key][wr_id] = $row2[wr_id];
$list1[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
$list1[$key][comment] = $row2[wr_comment];
$list1[$key][comment_cnt] = "($row2[wr_comment])";
$key = substr('00000'.$row2[wr_hit],-5) . '-' . $row2[wr_id];
$list2[$key][subject] = conv_subject($row2[wr_subject],22,'…');
$list2[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list2[$key][bo_table] = $row[bo_table];
$list2[$key][wr_id] = $row2[wr_id];
$list2[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
$list2[$key][wr_hit] = $row2[wr_hit];
$list2[$key][hit] = "($row2[wr_hit])";
$list2[$key][content] = cut_str(get_text($row2[wr_content]), 80);
$list2[$key][file][0][file] = $row2[file][1][file];
$list2[$key][comment] = $row2[wr_comment];
$list2[$key][comment_cnt] = "[$row2[wr_comment]]";
}
}
krsort($list2);
$latest_skin_path = "$g4[path]/skin/latest/rank";
?>
<table width="595" border="0" cellspacing="0" cellpadding="0">
<tr>
<?
$i=0;
foreach($list2 as $key=>$value) {
if ($i++>=($top1)) break;
?>
<td align=left valign=top style='word-break:break-all;'>
<?
//이미지 찾아오기 1
$sql_1 = " select bf_file from `$g4[board_file_table]` where bo_table = '{$list2[$key][bo_table]}' and wr_id = '{$list2[$key][wr_id]}' order by bf_no limit 1 ";
$result_1 = mysql_fetch_array(sql_query($sql_1));
//썸네일경로 사용할경우
$data_path = "$g4[path]/data/file/{$list2[$key][bo_table]}/thumbnail2/"; //게시판 업로드 기본경로
$list2[$key][bf_file] = $data_path . $list2[$key][wr_id]; //퍼일 전체경로 = 해당게시판 해당글의 파일명 : $result_1[bf_file]
$check = $list2[$key][bf_file];
if($i==1){
$image_check = @getimagesize($list2[$key][bf_file]); //이미지 유무판단을 위한 임시사용
if($image_check[0]){
$l_sub = cut_str(get_text($list2[$key][subject]), 24);
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='{$list2[$key][bf_file]}' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$l_sub}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>";
} else {
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='$g4[path]/img/bbs-noimg.gif' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$l_sub}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>"; //이미지가 아닌경우 또는 이미지가 없는경우
}
} else {
$image_check = @getimagesize($list2[$key][bf_file]); //이미지 유무판단을 위한 임시사용
if($image_check[0]){
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='{$list2[$key][bf_file]}' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$list2[$key][subject]}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>";
} else {
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='$g4[path]/img/bbs-noimg.gif' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$list2[$key][subject]}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>"; //이미지가 아닌경우 또는 이미지가 없는경우
}}
?>
</td>
<? } ?>
<? if (count($list2) == 0) { ?>
<td colspan=1 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td>
<? } ?>
</tr>
</table>
코멘트가 없을때 그냥 [0]자체가 안나오게 가능한지요.
물론 코멘트가 있으면 정상적으로 출력하구요.
답변 부탁을 드립니다. 감사합니다.
<?
include_once("./_common.php");
define("_CO_INDEX_", TRUE);
$html_title = "더쿠페";
$g4[title] = "" . $html_title;
include_once("./_head.php");
$before_day = 9; //게시물을 추출할기간설정
$before_time = date("Y-m-d H:i:s", $g4[server_time] - (86400 * $before_day));
$list1 = array();
$top1 = 5;
$bo_tables = "('gallery','clubgallery')"; // <-- board1~3은 원하는 게시판의 bo_table 값들
$sql = " select bo_table, bo_notice from $g4[board_table]
where bo_table in $bo_tables";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
$sql2 = " select * from $g4[write_prefix]$row[bo_table]
where wr_comment > -1
and wr_datetime >= '$before_time' ";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2))
{
$key = substr('00000'.$row2[wr_comment],-5) . '-' . $row2[wr_id];
$list1[$key][subject] = conv_subject($row2[wr_subject],22,'…');
$list1[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list1[$key][bo_table] = $row[bo_table];
$list1[$key][wr_id] = $row2[wr_id];
$list1[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
$list1[$key][comment] = $row2[wr_comment];
$list1[$key][comment_cnt] = "($row2[wr_comment])";
$key = substr('00000'.$row2[wr_hit],-5) . '-' . $row2[wr_id];
$list2[$key][subject] = conv_subject($row2[wr_subject],22,'…');
$list2[$key][href] = "$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row2[wr_id]";
$list2[$key][bo_table] = $row[bo_table];
$list2[$key][wr_id] = $row2[wr_id];
$list2[$key][is_notice] = preg_match("/[^0-9]{0,1}{$row2[wr_id]}[\r]{0,1}/",$row[bo_notice]);
$list2[$key][wr_hit] = $row2[wr_hit];
$list2[$key][hit] = "($row2[wr_hit])";
$list2[$key][content] = cut_str(get_text($row2[wr_content]), 80);
$list2[$key][file][0][file] = $row2[file][1][file];
$list2[$key][comment] = $row2[wr_comment];
$list2[$key][comment_cnt] = "[$row2[wr_comment]]";
}
}
krsort($list2);
$latest_skin_path = "$g4[path]/skin/latest/rank";
?>
<table width="595" border="0" cellspacing="0" cellpadding="0">
<tr>
<?
$i=0;
foreach($list2 as $key=>$value) {
if ($i++>=($top1)) break;
?>
<td align=left valign=top style='word-break:break-all;'>
<?
//이미지 찾아오기 1
$sql_1 = " select bf_file from `$g4[board_file_table]` where bo_table = '{$list2[$key][bo_table]}' and wr_id = '{$list2[$key][wr_id]}' order by bf_no limit 1 ";
$result_1 = mysql_fetch_array(sql_query($sql_1));
//썸네일경로 사용할경우
$data_path = "$g4[path]/data/file/{$list2[$key][bo_table]}/thumbnail2/"; //게시판 업로드 기본경로
$list2[$key][bf_file] = $data_path . $list2[$key][wr_id]; //퍼일 전체경로 = 해당게시판 해당글의 파일명 : $result_1[bf_file]
$check = $list2[$key][bf_file];
if($i==1){
$image_check = @getimagesize($list2[$key][bf_file]); //이미지 유무판단을 위한 임시사용
if($image_check[0]){
$l_sub = cut_str(get_text($list2[$key][subject]), 24);
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='{$list2[$key][bf_file]}' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$l_sub}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>";
} else {
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='$g4[path]/img/bbs-noimg.gif' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$l_sub}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>"; //이미지가 아닌경우 또는 이미지가 없는경우
}
} else {
$image_check = @getimagesize($list2[$key][bf_file]); //이미지 유무판단을 위한 임시사용
if($image_check[0]){
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='{$list2[$key][bf_file]}' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$list2[$key][subject]}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>";
} else {
echo "<table width=116 cellpadding=0 cellspacing=0 border=0>
<tr><td align=left valign=top width=116 height=120><a href='{$list2[$key][href]}'><img src='$g4[path]/img/bbs-noimg.gif' border=0 width=108 height=108 class=img1></a></td></tr>
<tr><td><a href='{$list2[$key][href]}'>{$list2[$key][subject]}</a> <span class='fontgreen text8'>{$list2[$key][comment_cnt]}</span></td></tr></table>"; //이미지가 아닌경우 또는 이미지가 없는경우
}}
?>
</td>
<? } ?>
<? if (count($list2) == 0) { ?>
<td colspan=1 align=center height=30 background="<?=$latest_skin_path?>/img/board_bg_line.gif">게시물이 없습니다.</td>
<? } ?>
</tr>
</table>
댓글 전체
$list2[$key][comment_cnt] = "[$row2[wr_comment]]";
부분을
if($row2[wr_comment]>0) $list2[$key][comment_cnt] = "[$row2[wr_comment]]";
로 바꿔보세요.
부분을
if($row2[wr_comment]>0) $list2[$key][comment_cnt] = "[$row2[wr_comment]]";
로 바꿔보세요.
와......전진님 정말 감사합니다..........^^ 잘 되네요 ㅎㅎ;;;;;;;