월별로 된 포인트순위를 원하는 기간으로 바꾸기 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

월별로 된 포인트순위를 원하는 기간으로 바꾸기 정보

월별로 된 포인트순위를 원하는 기간으로 바꾸기

본문

소스인데요..
월별 포인트 랭킹 소스입니다.
보면 시작월을 설정하여 2011-08월 / 2011-09월 이런식으로 셀렉트 박스가 나와
그 달의 포인트 랭킹을 보여주는데요.

이부분을 직접 원하는 " 년/월 ~ 년/월"까지 검색이 가능하게 하고 싶습니다.

도와주세요~ ㅠㅠ

======================================================================================
<?
include_once("./_common.php");
@include_once("$g4[path]/lib/mw.builder.lib.php");

// 시작월
$start_month = "2011-08";

$months = array();
$sql = "select left(po_datetime, 7) as month from $g4[point_table] where left(po_datetime, 7) >= '$start_month' group by month";
$qry = sql_query($sql);
for ($i=0; $row=sql_fetch_array($qry); $i++) {
    $months[$i] = $row[month];
}
$months_count = count($months);

if (!$month)
    $month = $months[$months_count-1];

if (!in_array($month, $months))
    alert("월 선택이 잘못되었습니다.");

$rows = 100;

$sql = "select mb_id, sum(po_point) as point, left(po_datetime, 7) as month
  from $g4[point_table]
where left(po_datetime, 7) = '$month'
        group by mb_id, month
        order by point desc";
$qry = sql_query($sql);

$i = 0;
$list = array();
while ($row = sql_fetch_array($qry)) {
    $mb = get_member($row[mb_id]);
    if ($row[mb_id] == $config[cf_admin]) continue;
    if ($mb[mb_level] < 2) continue;
    if ($mb[mb_leave_datel] != "") continue;
    if ($mb[mb_intercept_datel] != "") continue;
    $list[$i][rank] = $i+1;
    $list[$i][name] = get_sideview($mb[mb_id], $mb[mb_nick], $mb[mb_email]. $mb[mb_homepage]);
    $list[$i][point] = number_format($row[point]);
    if (++$i >= $rows) break;
}

$list_count = sizeof($list);

//$paging = get_paging($rows, $page, $total_page, "?page=");
 
$g4[title] = "월별 포인트순위";
?>

<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>

<style type="text/css">
.info { height:25px; margin:0 0 0 10px; font-size:13px; }
.line { border-top:1px solid #ddd; margin:10px 0 10px 0; }
.point-ranking { }
.point-ranking .head { font-weight:bold; text-align:center; height:30px }
.point-ranking .body { height:30px; padding:0; }
.point-ranking .body .rank { width:50px; text-align:right; }
.point-ranking .body .name { width:150px; text-align:left; padding-left:5px; }
.point-ranking .body .point { width:100px; text-align:right; }
.paging { clear:both; height:50px; text-align:center; margin:30px 0 0 0; }
</style>


<strong><?=$g4[title]?></strong>
&nbsp;&nbsp;&nbsp;
<select id="month" name="month" onchange="location.href='<?=$_SERVER[PHP_SELF]?>?month='+this.value">;
<? for ($i=$months_count-1; $i>=0; $i--) { ?>
<option value="<?=$months[$i]?>"><?=$months[$i]?></option>
<? } ?>
</select>
<script type="text/javascript"> document.getElementById("month").value = "<?=$month?>"; </script>

<div class="line"></div>

<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
    <td width="50%" valign="top">
<table border=0 cellpadding=0 cellspacing=0 class="point-ranking">
<? for ($i=0; $i<$rows/2 && $i<$list_count; $i++) { ?>
<tr>
    <td class="body"> <div class="rank"><?=$list[$i][rank]?>.</div> </td>
    <td class="body"> <div class="name"><?=$list[$i][name]?></div> </td>
    <td class="body"> <div class="point"><?=$list[$i][point]?> 점</div> </td>
</tr>
<? } ?>
</table>
    </td>
    <td width="50%" valign="top">
<table border=0 cellpadding=0 cellspacing=0 class="point-ranking">
<? for ($i=$rows/2; $i<$list_count; $i++) { ?>
<tr>
    <td class="body"> <div class="rank"><?=$list[$i][rank]?>.</div> </td>
    <td class="body"> <div class="name"><?=$list[$i][name]?></div> </td>
    <td class="body"> <div class="point"><?=$list[$i][point]?> 점</div> </td>
</tr>
<? } ?>
</table>
    </td>
</tr>
</table>

<div class="line"></div>

<div class="paging"><?=$paging?></div>

===================================================

댓글 전체

쿼리를 공부해 보세여~
$sql = "select left(po_datetime, 7) as month from $g4[point_table] where left(po_datetime, 7) >= '$start_month' group by month";

위 쿼리를 편집!  시작월부터 종료월까지 뽑으라고 바꿔주기~
$start_month = $_GET[smon]; //시작월을 변수값으로 받기
$end_month = $_GET[emon]; //종료월을 변수값으로 받기

$sql = "select left(po_datetime, 7) as month from $g4[point_table] where left(po_datetime, 7) >= '$start_month' and left(po_datetime, 7) <= '$end_month' group by month";

//이렇게 바꾸고 변수값을 url에 달아서 보내보면 테스트가 되겠죠
//  예제)  http://test.com/bbs/test.php?smon=2011-01&emon=2011-09
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT