기간별 베스트 맴버
본문
안녕하세요
커뮤니티에 주간 베스트맴버 3명을 뽑고(포인트 획득순)
1~3위까지 별 닉네임옆에 마크를달아주고싶은데요
혹시좋은방안있을까요;-;
답변 2
/* 1주일 구하기 (전주 월 ~ 일) */
$today = time();
$week = date("w");
$week_first = $today-($week*86400);
$week_last = $week_first+(6*86400);
$start_date = date("Y-m-d",$week_first-(86400*6))." 00:00:00";
$end_date = date("Y-m-d",$week_last-(86400*6))." 23:59:59";
/* 1주일 기간내에 포인트 합계 3위까지 구하기 */
$sql = "SELECT `mb_id`, sum(po_point) FROM `g5_point` WHERE `po_datetime` >= '".$start_date."' AND `po_datetime` <= '".$end_date."' GROUP BY `mb_id` ORDER by sum(po_point) DESC limit 3";
$result = sql_query($sql);
/* 3위까지 배열에 담기 */
$week_rank= array();
while($row=sql_fetch_array($result)) {
$week_rank[] = $row['mb_id'];
}
예를 들어서 게시판 목록에 표시한다고 하시면
해당 게시판 스킨 list.skin.php 상단에 저렇게 하시고
해당 게시판 이름을 $list[$i]['name'] 표시한다면
for ($i=0; $i<count($list); $i++) { 다음에
if($list[$i]['mb_id'] == $week_rank[0]){ //1등
$list[$i]['name'] = $list[$i]['name']."(1등)";
}else if($list[$i]['mb_id'] == $week_rank[1]){ //2등
$list[$i]['name'] = $list[$i]['name']."(2등)";
}else if($list[$i]['mb_id'] == $week_rank[2]){ //3등
$list[$i]['name'] = $list[$i]['name']."(3등)";
}
해보세요.
!-->!-->주간 포인트 획득 합계를 저장하는 컬럼을 하나 만드시는 것이 좋을 듯합니다.
답변을 작성하시기 전에 로그인 해주세요.