안녕하세요
특정 게시판의 게시물 총 수를 구하려고 합니다.
<?php
$bo_table = "test";
$write_table = $g5['write_prefix'] . $bo_table;
$sql_common = " from {$write_table} ";
$sql_txt_rdy .= " and wr_id = 'wr_parent' ";
$sql = " select count(*) as cnt $sql_common $sql_txt_rdy";
$row = sql_fetch($sql);
$txt_rdy_cnt = $row['cnt'];
?>
<?php echo $txt_rdy_cnt ?>
wr_parent 부분을 없애면 댓글 수량까지 전부나와서요..
틀린곳좀 알려주세요..ㅠㅠ
답변 5개
채택된 답변
+20 포인트
Copy
$bo_table = "test";
$write_table = $g5['write_prefix'] . $bo_table;
$sql_common = " from {$write_table} ";
$sql_txt_rdy = ' where 1 = 1 ';
$sql_txt_rdy .= " and wr_id = wr_parent ";
$sql = " select count(*) as cnt $sql_common $sql_txt_rdy";
$row = sql_fetch($sql);
$txt_rdy_cnt = $row['cnt'];
엄밀히 하자면 wr_id = 'wr_parent' <=== 이것은 답글을 사용하면 원글수 + 답글수가 됩니다
따라서
sql_query("select count(*) as cnt from $write_table where wr_replay='' and wr_is_comment=0 ");
답글을 사용하지 않는 게시판이면
sql_query("select count(*) as cnt from $write_table where wr_is_comment=0 ");
채택한 질문이지만 차후 질문을 참고할 분이 있을 것으로 보고 답변 남깁니다
답변을 작성하려면 로그인이 필요합니다.