채택완료

g5_board_new 가 게시물/댓글 전체 정보를 가지고 있나요?

2019-06-20 (목) 01:26:26 2,803

사용자가 쓴 게시물수랑 댓글 수를 이런식으로 추출해도 될까요?

Copy
//게시물수

        $memid = $member['mb_id'];
        $sql = "select count(*) as cnt from g5_board_new where wr_id = wr_parent and mb_id = '$memid'";
        echo $sql;
        $row = sql_fetch($sql);
        $u_post = $row['cnt'];

 

//댓글수

        $sql = "select count(*) as cnt from g5_board_new where wr_id != wr_parent and mb_id = '$memid'";
        echo $sql;
        $row = sql_fetch($sql);
        $u_reply = $row['cnt'];

답변 2개 / 댓글 2개

채택된 답변
+20 포인트
2019-06-20 (목) 20:52:51
Copy
$sql = " 
    select bo_table
      from {$g5['board_table']} 
";

 

$result = sql_query($sql);

for ($i = 0; $row = sql_fetch_array($result); $i++) {
  $tmp_write_table = $g5['write_prefix'].$row['bo_table'];
  
  $sql = " select count(*) as cnt from {$tmp_write_table} where mb_id = '{$member['mb_id']}' and wr_is_comment = 0";  
  $row2 = sql_fetch($sql);
  
  $tot_cnt += $tot_cnt + (int) $row2['cnt'];
  
  $sql = " select count(*) as cnt_cmt from {$tmp_write_table} where mb_id = '{$member['mb_id']}' and wr_is_comment = 1";  
  $row2 = sql_fetch($sql);
  $tot_cnt_cmt += (int) $row2['cnt_cmt'];
  
}    

 

echo $tot_cnt;
echo '/';
echo $tot_cnt_cmt;

환경설정 > 기본환경설정 > 최근게시물 삭제 

여기에 설정된 이후는 삭제됩니다.

답변에 대한 댓글 2개

그럼 혹시 전체게시물 중 내가 작성한 글과 댓글 수를 가져오려면 어떻게 하면 좋을까요?
g5_board 에서 전체 게시판을 불러와서..
while 문이나 for 문으로 게시판별 수량을 구해서 더해야 합니다.

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