나의 최근게시물을 특정 게시판에서만 가져 오려면.. 정보
나의 최근게시물을 특정 게시판에서만 가져 오려면..
본문
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=44287
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="7" height="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p1.gif"></td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p5.gif"></td>
<td width="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p2.gif"></td>
</tr>
<tr>
<td background="<?=$new_my_skin_path?>/img/line_mid_p8.gif"></td>
<td>
<?
$sql2 = " select count(*) as cnt from $g4[board_new_table]
where wr_id = wr_parent and mb_id = '$member[mb_id]' ";
$row2 = sql_fetch($sql2);
$total_count = number_format($row2[cnt]);
$rows = $page_count;
$total_page = ceil($total_count / $rows);
if (!$scpage) { $scpage = 1; }
$from_record = ($scpage - 1) * $rows;
$sql = " select bo_table, wr_id, wr_parent from $g4[board_new_table] a
where mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc limit $from_record, $new_count ";
$res = sql_query($sql);
echo "<table width=95% cellpadding=0 cellspacing=0 align=center>";
echo "<tr height=25><td><img src='$new_my_skin_path/img/list_icon.gif'> <a href='$g4[bbs_path]/new.php?view=w&mb_id=$member[mb_id]'><span style='color:#333333;'><b>나의 최근게시물 ({$total_count}) </b></span></a></td></tr><tr><td height=1 bgcolor=#FF9900></td></tr>";
$list = array();
for ($i=0; $row=sql_fetch_array($res), $i<$new_count; $i++)
{
if (!$row[bo_table])
{
continue;
}
$tmp_table = $g4[write_prefix].$row[bo_table];
$sql2 = " select wr_subject, wr_comment from $tmp_table where wr_id = '$row[wr_parent]' ";
$row2 = sql_fetch($sql2);
$list[$i] = $row2;
$subj = get_text($list[$i][wr_subject]);
$subj = cut_str($subj, $subjc);
$comment = "";
if ($list[$i][wr_comment])
$comment = "<span class=small>({$list[$i][wr_comment]})</span>";
echo "<tr height=23><td class=bg_menu2 title='$subj'>";
echo "<nobr style='display:block;overflow:hidden;width:160px;'>";
echo "<img src='$new_my_skin_path/img/list_icon2.gif'> <a href='$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row[wr_parent]'>";
echo "<span style='color:#666666;'>$comment $subj</span></a>";
echo "</nobr></td></tr>";
}
if (!$total_count) {
echo "<tr><td><span style='color:gray;'>게시글이 없습니다.</span></td></tr>";
}else{
echo "<tr><td><span style='color:gray;'>";
$scpage = get_paging($page_count, $scpage, $total_page, "?gr_id=$gr_id&bo_table=$bo_table&scpage=");
echo "$scpage";
echo "</span></td></tr>";
}
echo "</table>\n";
?>
</td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p6.gif"></td>
</tr>
<tr>
<td height="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p4.gif"></td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p7.gif"></td>
<td><img src="<?=$new_my_skin_path?>/img/line_mid_p3.gif"></td>
</tr>
</table>
<?
} else {
echo "로그인을 하셔야 보입니다.";
}
?>
위의 팁의 헐랭이 님의 나의 최근 게시물입니다.
전체 게시판에서 최근 게시물을 가져오는데..
전체 게시판이 아닌 특정 게시판에서 자기 글만 가져오게 하고 싶습니다.
고수님들 부탁드릴께요..
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="7" height="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p1.gif"></td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p5.gif"></td>
<td width="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p2.gif"></td>
</tr>
<tr>
<td background="<?=$new_my_skin_path?>/img/line_mid_p8.gif"></td>
<td>
<?
$sql2 = " select count(*) as cnt from $g4[board_new_table]
where wr_id = wr_parent and mb_id = '$member[mb_id]' ";
$row2 = sql_fetch($sql2);
$total_count = number_format($row2[cnt]);
$rows = $page_count;
$total_page = ceil($total_count / $rows);
if (!$scpage) { $scpage = 1; }
$from_record = ($scpage - 1) * $rows;
$sql = " select bo_table, wr_id, wr_parent from $g4[board_new_table] a
where mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc limit $from_record, $new_count ";
$res = sql_query($sql);
echo "<table width=95% cellpadding=0 cellspacing=0 align=center>";
echo "<tr height=25><td><img src='$new_my_skin_path/img/list_icon.gif'> <a href='$g4[bbs_path]/new.php?view=w&mb_id=$member[mb_id]'><span style='color:#333333;'><b>나의 최근게시물 ({$total_count}) </b></span></a></td></tr><tr><td height=1 bgcolor=#FF9900></td></tr>";
$list = array();
for ($i=0; $row=sql_fetch_array($res), $i<$new_count; $i++)
{
if (!$row[bo_table])
{
continue;
}
$tmp_table = $g4[write_prefix].$row[bo_table];
$sql2 = " select wr_subject, wr_comment from $tmp_table where wr_id = '$row[wr_parent]' ";
$row2 = sql_fetch($sql2);
$list[$i] = $row2;
$subj = get_text($list[$i][wr_subject]);
$subj = cut_str($subj, $subjc);
$comment = "";
if ($list[$i][wr_comment])
$comment = "<span class=small>({$list[$i][wr_comment]})</span>";
echo "<tr height=23><td class=bg_menu2 title='$subj'>";
echo "<nobr style='display:block;overflow:hidden;width:160px;'>";
echo "<img src='$new_my_skin_path/img/list_icon2.gif'> <a href='$g4[bbs_path]/board.php?bo_table=$row[bo_table]&wr_id=$row[wr_parent]'>";
echo "<span style='color:#666666;'>$comment $subj</span></a>";
echo "</nobr></td></tr>";
}
if (!$total_count) {
echo "<tr><td><span style='color:gray;'>게시글이 없습니다.</span></td></tr>";
}else{
echo "<tr><td><span style='color:gray;'>";
$scpage = get_paging($page_count, $scpage, $total_page, "?gr_id=$gr_id&bo_table=$bo_table&scpage=");
echo "$scpage";
echo "</span></td></tr>";
}
echo "</table>\n";
?>
</td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p6.gif"></td>
</tr>
<tr>
<td height="7"><img src="<?=$new_my_skin_path?>/img/line_mid_p4.gif"></td>
<td background="<?=$new_my_skin_path?>/img/line_mid_p7.gif"></td>
<td><img src="<?=$new_my_skin_path?>/img/line_mid_p3.gif"></td>
</tr>
</table>
<?
} else {
echo "로그인을 하셔야 보입니다.";
}
?>
위의 팁의 헐랭이 님의 나의 최근 게시물입니다.
전체 게시판에서 최근 게시물을 가져오는데..
전체 게시판이 아닌 특정 게시판에서 자기 글만 가져오게 하고 싶습니다.
고수님들 부탁드릴께요..
댓글 전체
$sql2 = " select count(*) as cnt from $g4[board_new_table]
where bo_table='SOME_BO_TABLE' and wr_id = wr_parent and mb_id = '$member[mb_id]' ";
index 추가 권장합니다.
where bo_table='SOME_BO_TABLE' and wr_id = wr_parent and mb_id = '$member[mb_id]' ";
index 추가 권장합니다.
감사합니다.^^
아래쪽에 $sql 쪽도 where 절만 주니 잘되네요
index 추가 하라는건 어떻게 해야 되나요??
아래쪽에 $sql 쪽도 where 절만 주니 잘되네요
index 추가 하라는건 어떻게 해야 되나요??