테스트 사이트 - 개발 중인 베타 버전입니다

메인에 평점(숫자)만 노출하고 싶은데 어려울까요? 채택완료

토토로2514 3년 전 조회 2,266

결과값이 0.0으로 나오네요 게시물 평점은 8.7인데요..ㅜㅜ 

도와주세요

 

사용스킨은 https://sir.kr/g5_skin/10430 입니다.

 

 

 

코드

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨 add_stylesheet('', 0); $thumb_width = (isset($options['thumb_w']) && $options['thumb_w'] > 0) ? $options['thumb_w'] : 235; $thumb_height = (isset($options['thumb_h']) && $options['thumb_h'] > 0) ? $options['thumb_h'] : 149; $list_count = (is_array($list) && $list) ? count($list) : 0;

 

$colspan = 5;

if ($is_checkbox) $colspan++; if ($is_good) $colspan++; if ($is_nogood) $colspan++;

?>

        

        if($thumb['src']) {             $img = $thumb['src'];         } else {             $img = G5_IMG_URL.'/no_img.png';             $thumb['alt'] = '이미지가 없습니다.';         }         $img_content = ''.$thumb['alt'].'';         $wr_href = get_pretty_url($bo_table, $list[$i]['wr_id']);

        if ($list[$i]['icon_new']) $icon_new = "N새글";         if ($list[$i]['icon_hot']) $icon_hot = "H인기글";

        $div_style = ($i!=0)?' style="display:none"':''; ?>

        

            

                    

  • 평점

    $average = ($row['total'] && $row['cnt']) ? $row['total'] / $row['cnt'] : 0;

    ?>

                        

                        

                    

  •                                  

                    

                

        

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

답변 1개

채택된 답변
+20 포인트

https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html

단순히 평균을 구하는 거면

Average() 함수를 검토해 보세요

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

엑스엠엘
3년 전
$row = sql_fetch(" select count(*) as cnt, sum(is_score) as total from {$g5['group']} where it_id = '{$it_id}' ");
그리고 여기서
sql이 원하는 대로 나오는지
Echo로 출력해서 확인해 보세요

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

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

로그인