답변 3개 / 댓글 4개
채택된 답변
+20 포인트
본문(view)에서 댓글들의 wr_20값이 있는경우의 평균값을 구할때??
Copy
<?php
$avg= sql_fetch("select avg(wr_20) as wr_20 from $write_table where wr_parent = '{$view['wr_id']}' and wr_is_comment = '1' and wr_20 <> '' ");
echo $avg['wr_20'];
?>
답변에 대한 댓글 3개
bbs/view_comment.php 여시면
Copy
// 코멘트 출력
//$sql = " select * from {$write_table} where wr_parent = '{$wr_id}' and wr_is_comment = 1 order by wr_comment desc, wr_comment_reply ";
$sql = " select * from $write_table where wr_parent = '$wr_id' and wr_is_comment = 1 order by wr_comment, wr_comment_reply ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
{ 다음 줄에
$total += $list[$i]['wr_20'] 넣고
Copy
}
// 코멘트수 제한 설정값
if ($is_admin)
{
$comment_min = $comment_max = 0;
}
else
{
$comment_min = (int)$board['bo_comment_min'];
$comment_max = (int)$board['bo_comment_max'];
}
'// 코멘트수 제한 설정값' 위에 echo $total / ($i+1) 하시면 됩니다.
답변을 작성하려면 로그인이 필요합니다.