그림자밟기

회원 나이별 게시물 통계 및 나이별 회원수

2010-08-28 13;44;13.JPG
통계관련 작업하려다가 나온 부산물이네요.
나이별 게시물 통계는 서브쿼리를 사용하기 때문에 my-sql 버젼이 4.1 인가 부터 가능할듯 합니다.
adm 폴더안에 파일생성하시면 되겠네요.

통계관련 작업이 끝나면 정리해서 올리도록 하겠습니다.
1% 미만은 비율표시에서 제했습니다.



<?
//$sub_menu = "200700";
include_once('./_common.php');
//auth_check($auth[$sub_menu], "r");
// 출력 시작
//$g4[title] = "사이트 활성도 통계";
//include_once("$g4[admin_path]/admin.head.php");
//회원연령별 통계
$sql = "select count(mb_id) as count,left(mb_birth,4) as birth from $g4[member_table] group by left(mb_birth,4) order by mb_birth desc"; 
$result = sql_query($sql); 
while($row = mysql_fetch_array($result)) {
if($row['birth']){
$age = date("Y")-$row['birth']+1;
$ageList[$age] = $row['count'];
$total = $total+$row['count'];
}
}
//$ageList['총'] = $total;
$ageList_Max = max($ageList);
$_Max1[$ageList_Max] = "background-color:#f1ffff;";

$sql = "
SELECT sum( count ) AS sum, left( mb_birth, 4 ) AS birth
FROM (
SELECT g4_member.mb_id, g4_member.mb_birth, count( * ) AS count
FROM g4_member
INNER JOIN g4_board_new ON g4_member.mb_id = g4_board_new.mb_id
GROUP BY g4_board_new.mb_id
)a
GROUP BY left( mb_birth, 4 ) 
ORDER BY left( mb_birth, 4 ) DESC 
";
$result = sql_query($sql); 
while($row = mysql_fetch_array($result)) {
if($row['birth']){
$age = date("Y")-$row['birth']+1;
$ageList2[$age] = $row['sum'];
$total2 = $total2+$row['sum'];
}
}
//$ageList2['총'] = $total2;
$ageList2_Max = max($ageList2);
$_Max2[$ageList2_Max] = "background-color:#f1ffff;";


?>
<style type="text/css">
#sh_table {float:left; margin:5px; border:2px solid #ddd; border-collapse:collapse;}
#sh_table th, #sh_table td {padding:3px; text-align:right; font-family:dotum; font-size:12px; border:1px solid #dedede; border-collapse:collapse; color:#555;}
#sh_table th {font-weight:bold; text-align:center;}
#sh_table .sh_title, #sh_table .sh_title2  {background-color:#eef0ee;}
#sh_table .sh_title2 {width:70px;}
#sh_table .graph {padding:1px; border:2px solid #eee; border-left:none; background-color:#cce;}
#sh_table .graph_td {padding-left:0; width:100px; text-align:left; font-size:8pt; font-weight:bold; letter-spacing:-1px; }
</style>

<table id="sh_table">
<tr><th class="sh_title">나이</th><th class="sh_title2">명 수</th><th class="sh_title">비 율</th></tr>
<?
foreach($ageList as $age => $count) {
echo "<tr style='{$_Max1[$count]}'><th>{$age}</th>";
echo "<td>".number_format($count)."명</td>";
$persent = round($count/$total*100);
//if(!$persent ) $persent = round($count/$total*100,1);
//$width=$persent*5;
$ageList_Width = round((($count / $ageList_Max * 100) * 0.95));
echo "<td class='graph_td'><div class='graph' style='width:{$ageList_Width}%; '>";
if($persent) echo "{$persent}%";
else echo " ";
echo "</div></td></tr>";
}
?>
</table>

<table id="sh_table">
<tr><th class="sh_title">나이</th><th class="sh_title2">게시물 작성</th><th class="sh_title">비 율</th></tr>
<?
foreach($ageList2 as $age => $count) {
echo "<tr style='{$_Max2[$count]}'><th>{$age}</th>";
echo "<td>".number_format($count)."개</td>";
$persent = round($count/$total2*100);
$ageList2_Width = round((($count / $ageList2_Max * 100) * 0.95));
echo "<td class='graph_td'><div class='graph' style='width:{$ageList2_Width}%; '>";
if($persent) echo "{$persent}%";
else echo " ";
echo "</div></td></tr>";
}
?>
</table>


<? //include_once("$g4[admin_path]/admin.tail.php"); ?>

첨부파일

|

댓글 3개

감사 감사
통계에 관심 많은데 기대 하겠습니다
통계이외의 기능들도 많았으면 좋겠네요 예를들면 나이대별로 선택하여 미성년자의 계정은 삭제한다던가 하는..
댓글을 작성하시려면 로그인이 필요합니다.

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요. 나누면 즐거움이 커집니다.

+
제목 글쓴이 날짜 조회
15년 전 조회 2.3만
15년 전 조회 5,539
15년 전 조회 6,524
15년 전 조회 6,014
15년 전 조회 1.7만
15년 전 조회 1.3만
15년 전 조회 4,128
15년 전 조회 6,791
15년 전 조회 1.1만
15년 전 조회 5,175
15년 전 조회 5,289
15년 전 조회 3,747
15년 전 조회 5,755
15년 전 조회 4,043
15년 전 조회 7,268
15년 전 조회 6,152
15년 전 조회 5,697
15년 전 조회 4,533
15년 전 조회 5,205
15년 전 조회 6,430