포인트랭킹 버그 > 그누4 질문답변

그누4 질문답변

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

포인트랭킹 버그 정보

포인트랭킹 버그

본문

비회원 일때는 잘나오는데 로그인해서 보면 이렇게 잘 않 나옵니다.






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

$sql_common = " from $g4[member_table] ";
$sql_where = " where mb_id <> '$config[cf_admin]' and mb_level > 1 and mb_leave_date = '' and mb_intercept_date = '' ";
$sql_order = " order by mb_point desc";

$sql = "select sum(mb_point) as total_point
 $sql_common
 $sql_where";
$row = sql_fetch($sql);
$total_point = number_format($row[total_point]);

$sql = "select count(*) as cnt
 $sql_common
 $sql_where
 and mb_point > '$member[mb_point]'";
$row = sql_fetch($sql);
$my_rank = $row[cnt] + 1;

$sql = "select count(*) as cnt
 $sql_common
 $sql_where";
$row = sql_fetch($sql);
$total_count = $row[cnt];

$page = "";

$rows = 100;
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$sql = "select mb_id, mb_name, mb_nick, mb_email, mb_homepage, mb_point
 $sql_common
 $sql_where
 $sql_order
 limit $from_record, $rows";
$qry = sql_query($sql);

$list = array();
for ($i=0; $row=sql_fetch_array($qry); $i++) {
    $list[$i][rank] = number_format((($page - 1) * $rows) + $i + 1);
    $list[$i][name] = get_sideview($row[mb_id], $row[mb_nick], $row[mb_email]. $row[mb_homepage]);
    $list[$i][point] = number_format($row[mb_point]);
}

$list_count = sizeof($list);

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

<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>

<?
if ($is_member) {
echo "<div class='info'>· 현재 회원님의 포인트는 <strong>".number_format($member[mb_point])."</strong>점 이며, 순위는 <strong>{$my_rank}</strong>등 입니다.</div>";
echo "<div class='info'>· 전체 포인트 : <strong>{$total_point}</strong>점</div>";
}
?>

<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>

<?
include_once("_tail.php");
?>

  • 복사

댓글 전체

엉뚱한 query 문을 봤네요. 일단 틀린 데는 없어 보입니다.

<?php echo '<pre>'; print_r( $list); echo '</pre>'; ?>

목록 이후에 넣어서 값들이 들어 있는지 한번 살펴 보세요.
우선 올려 주신 소스로 확인 해보니 로그인에 상관없이 잘 나옵니다.

꼭 필요하신게 아니라면

include_once("$g4[path]/lib/mw.builder.lib.php");

이줄 삭제 하고 테스트 해보세요.

그리고 아래는 먼저 head.pphp 파일을 확인해 보셔야 겠지만

회원 수는 나오는데 값이 안나오는 것으로 미루어 변수명 중복인듯 싶어서 변수 이름을 바꿔 봤습니다.

참고 하세요~

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

$sql_common = " from $g4[member_table] ";
$sql_where = " where mb_id <> '$config[cf_admin]' and mb_level > 1 and mb_leave_date = '' and mb_intercept_date = '' ";
$sql_order = " order by mb_point desc";

$sql = "select sum(mb_point) as total_point
 $sql_common
 $sql_where";
$row = sql_fetch($sql);
$total_point = number_format($row[total_point]);

$sql = "select count(*) as cnt
 $sql_common
 $sql_where
 and mb_point > '$member[mb_point]'";
$row = sql_fetch($sql);
$my_rank = $row[cnt] + 1;

$sql = "select count(*) as cnt
 $sql_common
 $sql_where";
$row = sql_fetch($sql);
$total_count = $row[cnt];

$page = "";

$rows = 100;
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함

$sql = "select mb_id, mb_name, mb_nick, mb_email, mb_homepage, mb_point
 $sql_common
 $sql_where
 $sql_order
 limit $from_record, $rows";
$qry = sql_query($sql);

$list1 = array();
for ($i=0; $row=sql_fetch_array($qry); $i++) {
    $list1[$i][rank] = number_format((($page - 1) * $rows) + $i + 1);
    $list1[$i][name] = get_sideview($row[mb_id], $row[mb_nick], $row[mb_email]. $row[mb_homepage]);
    $list1[$i][point] = number_format($row[mb_point]);
}

$list_count = sizeof($list1);

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

<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>

<?
if ($is_member) {
echo "<div class='info'>· 현재 회원님의 포인트는 <strong>".number_format($member[mb_point])."</strong>점 이며, 순위는 <strong>{$my_rank}</strong>등 입니다.</div>";
echo "<div class='info'>· 전체 포인트 : <strong>{$total_point}</strong>점</div>";
}
?>

<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"><?=$list1[$i][rank]?>.</div> </td>
    <td class="body"> <div class="name"><?=$list1[$i][name]?></div> </td>
    <td class="body"> <div class="point"><?=$list1[$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"><?=$list1[$i][rank]?>.</div> </td>
    <td class="body"> <div class="name"><?=$list1[$i][name]?></div> </td>
    <td class="body"> <div class="point"><?=$list1[$i][point]?> 점</div> </td>
 </tr>
 <? } ?>
 </table>
    </td>
</tr>
</table>

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

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

<?
include_once("_tail.php");
?>
© SIRSOFT
현재 페이지 제일 처음으로