포인트 순위가 같을때 공동으로 순위표시좀 알려주세요

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
포인트 순위가 같을때 공동으로 순위표시좀 알려주세요

QA

포인트 순위가 같을때 공동으로 순위표시좀 알려주세요

본문

포인트 순위를 만들고 있는 중입니다

순위가 공동일때 4위 5위 6위 이런식으로 나오던데

공동순위이면 4위 4위 4위 7위 이런식으로 하는 방법좀 알려주세요 


					<?
						$sql = " select count(*) as cnt from $g5[member_table]";
						
						$row = sql_fetch($sql);
						$total_count = $row[cnt];
						 
						$rows = 10;
						$total_page  = ceil($total_count / $rows); 
						if ($page == "") { $page = 1; }
						$from_record = ($page - 1) * $rows; 
 
						$mod = 48;
						$tbl_col =2 ;
 
						$tbl_col_sep = (int)($mod / $tbl_col) + ($mod % $tbl_col)  ;
						if($_GET[keyword]!="")
						{
						if($_GET[type]==0)
						{
						$keyword_yi="where mb_nick='$_GET[keyword]'";
						}
						}
						$sql = " select * from $g5[member_table] where mb_id not in ('admin') $keyword_yi 
								  order by mb_point desc, mb_today_login desc 
								  limit $from_record, $rows ";
								  $sql11 = " select count(*) from $g5[member_table] $keyword_yi 
								  order by mb_point desc, mb_today_login desc 
								  ";
						$result = sql_query($sql);
						$result11 = sql_query($sql11);
						//echo $rsn11;
						$rsn11=mysql_fetch_array($result11);
						if($rsn11[0]==0)
						{
						if($_GET[type]==0)
						{
						$ty="닉네임";
						}
						echo "<tr><td colspan=6 align=center height=150> 검색하신 $ty(<font color=red>$_GET[keyword]</font>) 에 대한 검색결과가 없습니다</td></tr>";
						}
						$point_que = mysql_query($point_sql); 
						for ($i=0; $row=sql_fetch_array($result); $i++) 
						{
							$rank = (($page - 1) * $rows) + $i + 1;
							$point = number_format($row[mb_point]);
							$id = $row[mb_id];
						?>
 
						<tr>
							<th><?=$rank?></th>
							<th><?=$row[mb_name]?></th>
							<th><?=$point?> 점</th>
						</tr>
						 <?	} ?>
 

이 질문에 댓글 쓰기 :

답변 1

아랫부분을 이렇게 고쳐보세요.

테스트는 안해봤는데, 이런 개념으로 해보심 될거에요.

이전 값을 저장해뒀다가 비교하는 방식으로...

 


$point_que = mysql_query($point_sql); 
 
// 세션에 이전페이지에서 남은게 있으면 넣어준다.
$prev_point = ($_SESSION['prev_point'] > 0) ? $_SESSION['prev_point'] : 0; // 이전포인트
$prev_rank = ($_SESSION['prev_rank'] > 0) ? $_SESSION['prev_rank'] : 0; // 이전랭크
 
for ($i=0; $row=sql_fetch_array($result); $i++)  
{ 
 $rank = (($page - 1) * $rows) + $i + 1; 
 $point = number_format($row[mb_point]); 
 $id = $row[mb_id]; 
 
 // 이전 포인트과 지금 포인트가 같으면 랭크를 이전 랭크로 대신함
 if($prev_point == $point) $rank = $prev_rank; 
?>
 <tr> 
  <th><?=$rank?></th> 
  <th><?=$row[mb_name]?></th> 
  <th><?=$point?> 점</th> 
 </tr> 
<?
 $prev_point = $point; // 이번회차 포인트는 저장해둠
 $prev_rank = $rank; // 이번회차 랭크는 저장해둠
}
// 세션에 저장해 두었다가, 다음 페이지에서 처음 비교할때 사용한다.
$_SESSION['prev_point'] = $point;
$_SESSION['prev_rank'] = $rank;
?>​
 

 

에공 오타가 있었구나;;

답변을 작성하시기 전에 로그인 해주세요.
전체 124,637 | RSS
QA 내용 검색

회원로그인

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