관리자에서 레벨당 회원이 몇명인지 퍼센트로
본문
관리자에서 레벨당 회원이 몇명이 하려면
<?php
$row = sql_fetch("select count(*) as cnt from {$g5['member_table']} where mb_level='1'", false);
echo "".$row['cnt']."명 <br>".PHP_EOL;
?>
이렇게 하니까 되던데 이걸
회원이 100명이고 레벨 2회원이 10명이라면 10% 같이 퍼센트로도 확인할수 있을까요?
답변 1
$sql="select count(*) as cnt from {$g5['member_table']} where 1";
$total=sql_fetch($sql);
for($i=1; $i<=10; $i++){
$sql="select count(*) as cnt from {$g5['member_table']} where mb_level='{$i}'"; //2레벨 회원 검색
$res=sql_fetch($sql);
echo "Level".$i." : ".$res['cnt']."명 ";
$per=round(($res['cnt'] / $total['cnt']) * 100, 2);
echo "Level".$i." : ".$per."%"."<br>";
}
답변을 작성하시기 전에 로그인 해주세요.