내 클럽 리스트 순서 정렬 > 그누4 플러그인

그누4 플러그인

그누보드에는 여러가지 기능 추가가 쉽도록 제작 되었습니다.
플러그인의 저작권은 해당 플러그인 제작자님께 있으며, 그누보드의 저작권과 다를 수 있습니다.
플러그인 다운로드시 좋아요와 감사의 코멘트를 남기시면 제작자에게 큰 힘이됩니다. ^^y

내 클럽 리스트 순서 정렬 정보

내 클럽 리스트 순서 정렬

본문

외부에서 클럽을 사용하는데,
회원들이 가입된  셀렉트박스로 내 클럽을 선택할때 순서 정렬을 마음대로 할 수 있도록 한 코드입니다.
간단하지만, 앞으로 기능 추가 하시는데 도움이 되었으면 좋겠네요.

------user_club_order.php 가져오는 부분---------
<?
$g4_path = "../";
include_once("$g4_path/common.php");
include_once("$g4[path]/head.sub.php");
//include_once("$g4[path]/head.sub.php");

//CLUB READ
$sql = " select  DISTINCT  a.cb_id, a.cm_level, b.cb_name
  from nc_member as a
left join nc_club as b
on a.cb_id = b.cb_id
  where a.mb_id = '$member[mb_id]'
  order by a.cm_1 ";
$resultList = mysql_query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
/*
theSelFrom: from
type: U=UP, D=DOWN
*/
function moveOption(theSelFrom, type)
{
//find select option
for ( var i=0; i< theSelFrom.length; i++)
{
if(theSelFrom.options[i].selected)
{
if ( type=="U" && i != 0 ) swapOption (theSelFrom, i, i-1 );
if ( type=="D" && i != theSelFrom.length-1 ) swapOption (theSelFrom, i, i+1 );
break;
}
}
}

function swapOption(theSelFrom, oldIndex, newIndex)
{
var oldOption = new Option(theSelFrom.options[oldIndex].text, theSelFrom.options[oldIndex].value);
var newOption = new Option(theSelFrom.options[newIndex].text, theSelFrom.options[newIndex].value);

theSelFrom.options[oldIndex] = newOption;
theSelFrom.options[newIndex] = oldOption;
theSelFrom.selectedIndex = newIndex;
}

function getListData( theSelFrom, theReturnTo )
{
var list ="";

//readList
for ( var i=0; i< theSelFrom.length; i++)
{
list = list + "" + theSelFrom[i].value;
if ( i != theSelFrom.length - 1 ) list = list + "||";
}
theReturnTo.value = list;

}
</script>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:140;
height:180;
z-index:1;
left: 805;
top: 50;
}
-->
</style>
</head>
<body onload="getListData(document.getElementById('form').clubSelect, document.getElementById('form').listData);">

<!-- CONTENTS -->
<div align="center">
<b>내 클럽 순서 변경</b>
<br>
<br>
<form id="form" name="form" method="post" action="user_club_orderSubmit.php">

<input type="hidden" name="listData" value="">
<div align="right" style="width:350px">
<input type="button" name="up" id="up" value="위로 ▲" onclick="moveOption(this.form.clubSelect, 'U');getListData(this.form.clubSelect, this.form.listData);" style="width:70px;height:25px;"/>
<input type="button" name="down" id="down" value="아래로 ▼" onclick="moveOption(this.form.clubSelect, 'D');getListData(this.form.clubSelect, this.form.listData);" style="width:70px;height:25px;"/>
</div>

  <select name="clubSelect" size="20" multiple="multiple" id="list" style="width:350px" >
    <?
    for ($i=0; $row=mysql_fetch_array($resultList); $i++) {
        echo "<option value='$row[cb_id]'>".$row[cb_name]."</option>\n";
    }
    ?>
  </select>
<br /> <br />
 
  <input type="submit" value="순서 변경" style="width:100px;height:30px;"/>
</form>
</div>
<!-- CONTENTS -->

</body>
</html>


------user_club_orderSubmit.php 저장하는 부분---------

<?
$g4_path = "../";
include_once("$g4_path/common.php");
include_once("$g4[path]/lib/outlogin.lib.php");

$list = explode ( "||", $_POST['listData']);

//QUERY

for( $i=0; $i<sizeof($list); $i++)
{
$sql = "update nc_member set cm_1='".$i."' where cb_id='".$list[$i]."' and mb_id='".$member[mb_id]."'";
$result = mysql_query($sql);
//echo $sql."\n";
}
goto_url("./user_club_order.php");
?>

---user_club_select.php 실제로 사용자에게 보여지는 셀렉트 부분 ---

<!-- 클럽 바로가기 시작 -->
<?
//가입된 Club 읽어오기
$sql = " select  DISTINCT  a.cb_id, a.cm_level, b.cb_name
  from nc_member as a
left join nc_club as b
on a.cb_id = b.cb_id
  where a.mb_id = '$member[mb_id]'
  order by a.cm_1 ";
$result = mysql_query($sql);
?>
<select name="select" onChange="go_club(this.value);" style="width:150px;" >
    <option>▼ 내 클럽 가기</option>
    <?
    for ($i=0; $row=mysql_fetch_array($result); $i++) {
        echo "<option value='/solution/club/club_main.php?cb_id=$row[cb_id]'>".$row[cb_name]."</option>\n";
    }
    ?>
<option>--------------------------</option>
<option value="/solution/club/user_club_order.php">[내 클럽 순서 변경]</option>
</select>
<script language="javascript">
    function go_club(url)
    {
        if (url != "") {
            window.location.href = url;
        }
    }
</script>
추천
0

댓글 전체

감사합니다. 참조해서 적당한 곳에 넣을께요 ^^
오늘은 방문자 카운터 대수선에 하루를 다 써서 수정 항목은 1개이고 수정 파일은 여러개 입니다. ㅠ..ㅠ
전체 3,524 |RSS
그누4 플러그인 내용 검색

회원로그인

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