관리자에서 레벨당 회원이 몇명이 하려면
<?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개 / 댓글 1개
채택된 답변
+20 포인트
8년 전
Copy
$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>";
}
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.