게시글, 댓글 카운트를 메인에 출력하고 싶습니다.

게시글, 댓글 카운트를 메인에 출력하고 싶습니다.

QA

게시글, 댓글 카운트를 메인에 출력하고 싶습니다.

답변 3

본문

특정 게시판의 게시글 수를 메인화면에 출력하고 싶습니다.

추가적으로 특정게시판의 댓글 수도 별도로 메인화면에 출력하고 싶습니다.

 

<?php

$sql = "select count(*) as cnt from g5_write_00000";
$row=sql_fetch($sql);
echo $row['cnt'];
?>

 

이렇게 했더니 게시글 수와 댓글 수가 합쳐서 출력이 됩니다.

고수님들의 많은 가르침 부탁드립니다.

감사합니다.

이 질문에 댓글 쓰기 :

답변 3

아래처럼 해보세요.

g5_write_00000 부분 00000 게시판 아이디로 수정

<?php
$intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));
$sql = " select count(*) as today_count from g5_write_00000 where wr_datetime >= '$intime' and wr_is_comment=0" ;
$data = sql_fetch($sql);
$new_list = $data['today_count'];
 
$list_a = sql_fetch("select count(*) as bo_count_write from g5_write_00000 where wr_is_comment=0 ");
$list_a = $list_a['bo_count_write'];
 
$comment_a = sql_fetch("select count(*) as bo_count_comment from g5_write_00000 where wr_is_comment=1 ");
$comment_a = $comment_a['bo_count_comment'];
 
echo "새글 ".$new_list."<br>"; // 새글
echo "전체 게시글 수 ".$list_a."<br>"; // 전체 게시글 수
echo "전체 코멘트 수 ".$comment_a; // 전체 코멘트 수
?>

열공님 덕분에 잘 됩니다. 열공님은 정말 능력자입니다!!!
하나만 더 문의 드리겠습니다.

현재 출력형태가 "새글 1 전체 게시슬 수 1 전체 코멘트 수" 이렇게 일직선 상에 놓여져 있습니다.

이런형태를 아래의 형태로 바꾸려면 어떻게 해야 하는지요?

새글 /  전체 게시글 수 /  전체 코멘트 수
  1            1                      1 

관심가져 주셔서 감사드립니다.

<?php
$intime = date("Y-m-d H:i:s", time() - (int)(60 * 60 * 24));
$sql = " select count(*) as today_count from g5_write_00000 where wr_datetime >= '$intime' and wr_is_comment=0" ;
$data = sql_fetch($sql);
$new_list = $data['today_count'];
 
$list_a = sql_fetch("select count(*) as bo_count_write from g5_write_00000 where wr_is_comment=0 ");
$list_a = $list_a['bo_count_write'];
 
$comment_a = sql_fetch("select count(*) as bo_count_comment from g5_write_00000 where wr_is_comment=1 ");
$comment_a = $comment_a['bo_count_comment'];
?>


<table>
<tr>
<th>새글 </th><th>전체 게시글 수</th>전체 코멘트 수<th></th>
</tr>
<tr>
<td><?php echo $new_list?></td><td><?php echo $list_a?></td><td><?php echo $comment_a?></td>
</tr>
</table>

덕분에 잘 되고 있습니다.

제가 카운트 애니메이션을 사용하려 하는데요.

<script>
function numberCounter(target_frame, target_number) {
    this.count = 0; this.diff = 0;
    this.target_count = parseInt(target_number);
    this.target_frame = document.getElementById(target_frame);
    this.timer = null;
    this.counter();
};
    numberCounter.prototype.counter = function() {
        var self = this;
        this.diff = this.target_count - this.count;
   
        if(this.diff > 0) {
            self.count += Math.ceil(this.diff / 5);
        }
   
        this.target_frame.innerHTML = this.count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
   
        if(this.count < this.target_count) {
            this.timer = setTimeout(function() { self.counter(); }, 20);
        } else {
            clearTimeout(this.timer);
        }
    };

window.onload = function(){
new numberCounter("counter3", 999);
new numberCounter("counter2", 1123456);
new numberCounter("counter1", 15);

}
</script>


<p id="counter1"></p>
<p id="counter2"></p>
<p id="counter3"></p>


해당 소스는 임의지정된 숫자에 대해 애니메이션이 작동하는데요.
만들어 주신 카운트를 이 애니메이션을 적용하고 싶어서요.
혹시 가능한가요?
계속 귀찮게 해드려 죄송합니다.

아래처럼 하면 될듯요


window.onload = function(){
new numberCounter("counter3", <?php echo $new_list; ?>);
new numberCounter("counter2", <?php echo $list_a; ?>);
new numberCounter("counter1", <?php echo $comment_a; ?>);
}

그리고 새로운 질문은 새로 등록하심이....

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 7
© SIRSOFT
현재 페이지 제일 처음으로