순위 입력.. rank
페이지 정보
작성자 최고관리자 작성일 21-02-09 11:40 조회 12,962 댓글 0본문
// 입력시
$cu_uid = mysql_insert_id(); //입력시나 수정시 해당 uid
//해당 uid를 제외한 순위 업데이트
$Rsql = "select * from table_name where 조건문 order by rank";
$Rresult = mysql_query($Rsql);
$i = 1;
while ($Rrow = mysql_fetch_array($Rresult)){
if($i == $rank) $i++;
$RUsql = "update tabel_name set rank ='$i' where uid = '$Rrow[uid]'";
$RUresult = mysql_query ($RUsql);
$i++;
}
// 해당 uid 순위 update
$RUsql2 = "update table_name set rank ='$rank' where uid = '$cu_uid'";
$RUresult2 = mysql_query ($RUsql2);
######################################################################
function OrderBy($rank, $TableName, $uid) {
if(!$rank) $rank = 1;
$Rquery = mysql_query("select * from $TableName where uid != '$uid' order by rank");
$i = 1;
while($Rrow = mysql_fetch_array($Rquery)){
if($i == $rank) $i++;
$RUquery = mysql_query("update $TableName set rank = '$i' where uid='$Rrow[uid]'");
$i ++;
}
$RUquery = mysql_query("update $TableName set rank = '$rank' where uid='$uid'");
}
$cu_uid = mysql_insert_id(); //입력시나 수정시 해당 uid
//해당 uid를 제외한 순위 업데이트
$Rsql = "select * from table_name where 조건문 order by rank";
$Rresult = mysql_query($Rsql);
$i = 1;
while ($Rrow = mysql_fetch_array($Rresult)){
if($i == $rank) $i++;
$RUsql = "update tabel_name set rank ='$i' where uid = '$Rrow[uid]'";
$RUresult = mysql_query ($RUsql);
$i++;
}
// 해당 uid 순위 update
$RUsql2 = "update table_name set rank ='$rank' where uid = '$cu_uid'";
$RUresult2 = mysql_query ($RUsql2);
######################################################################
function OrderBy($rank, $TableName, $uid) {
if(!$rank) $rank = 1;
$Rquery = mysql_query("select * from $TableName where uid != '$uid' order by rank");
$i = 1;
while($Rrow = mysql_fetch_array($Rquery)){
if($i == $rank) $i++;
$RUquery = mysql_query("update $TableName set rank = '$i' where uid='$Rrow[uid]'");
$i ++;
}
$RUquery = mysql_query("update $TableName set rank = '$rank' where uid='$uid'");
}
댓글목록 0
등록된 댓글이 없습니다.