7쟁이님의 나의 최신글 스킨에서 한 그룹에서만 글을 뽑아 올 수는 없는지요? 정보
7쟁이님의 나의 최신글 스킨에서 한 그룹에서만 글을 뽑아 올 수는 없는지요?본문
7쟁이님의 나의 최신글 스킨을 사용하고 있는데 한 그룹에서만 최신글을 뽑아 오는
방법이 없는지요 초급이라 여러가지로 힘이듭니다.
매번 질문만 올리게 되어 부끄럽기도 하구요. 혹 알고 계시면 회원이 계시면 답변 주셨으면 합니다.
// 나의 최근게시물
if ($member[mb_id])
{
$new_count = 5;
if ($member[mb_id])
{
$new_count = 5;
$cnt = 0;
$sql = " select bo_table, 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 $new_count ";
$res = sql_query($sql);
$sql = " select bo_table, 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 $new_count ";
$res = sql_query($sql);
echo "<table width=95% cellpadding=0 cellspacing=0 align=center>";
echo "<tr height=25><td><img src='$g4[path]/my_view/img/list_icon.gif'> <span style='color:#333333;'><b>나의 최근게시물 </b></span></a></td></tr><tr><td height=1 bgcolor=#FF9900></td></tr>";
for ($i=0; $row=sql_fetch_array($res), $i<$new_count; $i++)
{
if (!$row[bo_table])
{
continue;
}
echo "<tr height=25><td><img src='$g4[path]/my_view/img/list_icon.gif'> <span style='color:#333333;'><b>나의 최근게시물 </b></span></a></td></tr><tr><td height=1 bgcolor=#FF9900></td></tr>";
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);
$subj = get_text($row2[wr_subject]);
$comment = "";
if ($row2[wr_comment])
$comment = "<span class=small>($row2[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='$g4[path]/my_view/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>";
$cnt++;
}
if (!$cnt)
echo "<tr><td><span style='color:gray;'>게시글이 없습니다.</span></td></tr>";
echo "</table>\n";
}
?>
$sql2 = " select wr_subject, wr_comment from $tmp_table where wr_id = '$row[wr_parent]' ";
$row2 = sql_fetch($sql2);
$subj = get_text($row2[wr_subject]);
$comment = "";
if ($row2[wr_comment])
$comment = "<span class=small>($row2[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='$g4[path]/my_view/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>";
$cnt++;
}
if (!$cnt)
echo "<tr><td><span style='color:gray;'>게시글이 없습니다.</span></td></tr>";
echo "</table>\n";
}
?>
댓글 전체
$sql = " select bo_table, 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 $new_count ";
==>
$sql = " select bo_table, wr_parent from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and b.gr_id = '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
===
인덱스 추가해야 할 듯합니다.
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 $new_count ";
==>
$sql = " select bo_table, wr_parent from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and b.gr_id = '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
===
인덱스 추가해야 할 듯합니다.
아래와 같이 에러가 납니다. 그리고 제가 무지해서 그런데 인덱스를 추가 해야 한다는 의미는 무엇인지요?
select bo_table, wr_parent from g4_board_new a, g4_board b where a.bo_table = b.bo_table and b.gr_id = 'apply' and mb_id = 'admin' -- and a.wr_id = a.wr_parent group by bo_table, wr_parent order by bn_id desc limit 5
1052 : Column: 'bo_table' in field list is ambiguous
error file : /board/bbs/member_confirm.php
select bo_table, wr_parent from g4_board_new a, g4_board b where a.bo_table = b.bo_table and b.gr_id = 'apply' and mb_id = 'admin' -- and a.wr_id = a.wr_parent group by bo_table, wr_parent order by bn_id desc limit 5
1052 : Column: 'bo_table' in field list is ambiguous
error file : /board/bbs/member_confirm.php
select bo_table, wr_parent
=>
select a.bo_table, a.wr_parent
a. 이빠졌네요.
=>
select a.bo_table, a.wr_parent
a. 이빠졌네요.
친절하신 답변에 감사드립니다.

rolo 님
저도 하나만 가르쳐 주세요 ..
저는 하나의 그룹을 제외하고 싶은데 어떻게 해야할까요?
부탁드릴께요..
저도 하나만 가르쳐 주세요 ..
저는 하나의 그룹을 제외하고 싶은데 어떻게 해야할까요?
부탁드릴께요..
$sql = " select bo_table, wr_parent from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and b.gr_id = '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
여기서
b.gr_id = '###그룹 아이디 #####'
여기만
b.gr_id != '###그룹 아이디 #####'
로 바꾸면 됩니다.
where a.bo_table = b.bo_table and b.gr_id = '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
여기서
b.gr_id = '###그룹 아이디 #####'
여기만
b.gr_id != '###그룹 아이디 #####'
로 바꾸면 됩니다.

고맙습니다. 얼른 적용해봐야겠네요.
^^ 친절한 답변감사드려요~~
$sql = " select a.bo_table, a.wr_parent from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and b.gr_id != '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
잘됩니다.
^^ 친절한 답변감사드려요~~
$sql = " select a.bo_table, a.wr_parent from $g4[board_new_table] a, $g4[board_table] b
where a.bo_table = b.bo_table and b.gr_id != '###그룹 아이디 #####'
and mb_id = '$member[mb_id]'
-- and a.wr_id = a.wr_parent
group by bo_table, wr_parent
order by bn_id desc
limit $new_count ";
잘됩니다.