채택완료

해당 게시판에 댓글 1회만 작성하게 하기

2023-12-04 (월) 19:29:52 1,943

A 게시판에 

1번글 - B가 댓글 달았음!

2번글 

3번글

이때 A게시판에서 B에게는 다른 글을 포함 모든글에 댓글창을 감췄으면 합니다.

<?php
$result = sql_fetch(" select count(*) as cnt from $write_table where wr_is_comment='1' and wr_parent='$view[wr_id]' and mb_id='$member[mb_id]'");
if($result['cnt']<"1") {
?>
    <div>
        댓글창
    </div>
<?php } ?> 

댓글을 단경우 댓글창을 감추는 코드는 위 코드로 적용이 되었는데,

해당글만 적용이 되어서요.

해당 게시판의 모든글에 적용하려면 어떻게 해야할까요?

|

답변 3개 / 댓글 4개

채택된 답변
+20 포인트
2023-12-05 (화) 09:17:23

회원에게는 안보이고 관리자에게는 보이는 거면 아래와 같이 진행해보세요.

Copy
<?php

$result = sql_fetch(" select count(*) as cnt from {$write_table} where wr_is_comment='1' and mb_id='{$member['mb_id']}'");

if($result['cnt'] < 1) {

?>

댓글창

<?php

}

?>
2023-12-05 (화) 01:06:10
$result = sql_fetch(" select count(*) as cnt from {$write_table} where wr_is_comment='1' and wr_parent='{$view['wr_id']}' and mb_id='{$member['mb_id']}'");

if ($result['cnt'] < 1) { 이거 아닌가요?

2023-12-04 (월) 19:37:28

and wr_parent='$view[wr_id]'

삭제

답변에 대한 댓글 4개

2023-12-04 (월) 20:04:43
네! 적용 잘되네요 감사해요 ㅎㅎ

근데 관리자한테도 적용되던데, 관리자는 적용되지 않게 하려면 어떻게해야할까요???
2023-12-04 (월) 20:19:20
if (!$is_admin && $result['cnt'] < "1") {
2023-12-04 (월) 20:44:54
관리자... 작동을 안해요 ㅜㅜ
2023-12-05 (화) 14:07:10
if ($is_admin || $result['cnt'] < 1) {

답변을 작성하려면 로그인이 필요합니다.