전체 포인트 말고 월별 포인트로 하고 싶습니다.

전체 포인트 말고 월별 포인트로 하고 싶습니다.

QA

전체 포인트 말고 월별 포인트로 하고 싶습니다.

답변 1

본문

전체 포인트로 백분율을 구하는걸 월별 포인트로 백분율 구하고 싶습니다.



<?php
$nowdate = date("Y-m",time()); // 이번달
//$nowdate = date("Y-m-d",time()); // 이번일
$sYear = substr($nowdate, 0, 4)."년";
$sMonth = substr($nowdate,5,2)."월";
//$sDay = substr($nowdate,8,2)."일";
$sql = "SELECT * , COUNT(B.mb_id ) AS count, SUM( B.po_point ) AS point
FROM  $g4[member_table] as A
LEFT JOIN $g4[point_table] as B ON ( A.mb_id = B.mb_id AND A.mb_level < 11 AND A.mb_point >= 1) where date_format(B.po_datetime,'%Y-%m') = '$nowdate' group by B.mb_id order by point desc LIMIT 0, 100 ";
$result = sql_query($sql);
?>



검색해서 찾은건데 월별 구하는거 같고 



<?php
// 전체회원수
$mbcnt_all_po = sql_fetch("select count(mb_id) as cnt from `$g4[member_table]`");
$sql_common = " and mb_id != '' ";
if ($mb['mb_id']) {
    $sql = " select count(mb_id) as cnt from {$g4[member_table]} where mb_point > '{$view_point}' {$sql_common} order by mb_point desc ";
    $row = sql_fetch($sql);
    $percent_cnt_po = intval(1 *$row['cnt']) / intval(1 * $mbcnt_all_po['cnt']) * 100;
    $percent_po_ct = round($percent_cnt_po, 0); // 반올림
    $percent_po = $percent_po_ct;
}

echo $percent_po;
?>


이건 전체 포인트 백분율 구하는거 입니다.


제가 초보라 어떻게 이 두개를 어떻게 합쳐야 될지 잘 모르겠습니다.

이 질문에 댓글 쓰기 :

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