여분필드값을 비교해서 출력하고싶습니다. 정보
여분필드값을 비교해서 출력하고싶습니다.
본문
// 포인트 부여
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='')
{
global $config;
global $g4;
global $is_admin;
// 포인트 사용을 하지 않는다면 return
if (!$config[cf_use_point]) { return 0; }
// 포인트가 없다면 업데이트 할 필요 없음
if ($point == 0) { return 0; }
// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == "") { return 0; }
$mb = sql_fetch(" select mb_id from $g4[member_table] where mb_id = '$mb_id' ");
if (!$mb[mb_id]) { return 0; }
// 이미 등록된 내역이라면 건너뜀
if ($rel_table || $rel_id || $rel_action)
{
$sql = " select count(*) as cnt from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ";
$row = sql_fetch($sql);
if ($row[cnt])
return -1;
}
// 포인트 건별 생성
$sql = " insert into $g4[point_table]
set mb_id = '$mb_id',
po_datetime = '$g4[time_ymdhis]',
po_content = '".addslashes($content)."',
po_point = '$point',
po_rel_table = '$rel_table',
po_rel_id = '$rel_id',
po_rel_action = '$rel_action' ";
sql_query($sql);
// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];
// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 누적의 합을 구하고
$sql = " select sum(if(po_point>0,po_point,0)) as sum_po_point from $g4[point_table] where mb_id='$mb_id'";
$row = sql_fetch($sql);
$point_acum = $row[sum_po_point];
// 포인트 mb_9 에 UPDATE//
$sql = " update $g4[member_table] set mb_9 = '$point_acum' where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 따라 회원 등급 바꾸기
if(!$is_admin){
if($point_acum >= 0 && $point_acum < 1500){
$new_level = 6;
}elseif($point_acum >= 1500 && $point_acum < 5000){
$new_level = 7;
}
$squery = ", mb_level = '$new_level'";
}
return 1;
}
// 포인트 삭제
function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
{
global $g4;
$result = false;
if ($rel_table || $rel_id || $rel_action)
{
$result = sql_query(" delete from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);
// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];
// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
}
// 포인트 누적의 합을 구하고
$sql = " select sum(if(po_point>0,po_point,0)) as sum_po_point from $g4[point_table] where mb_id='$mb_id'";
$row = sql_fetch($sql);
$point_acum = $row[sum_po_point];
// 포인트 mb_9 에 UPDATE//
$sql = " update $g4[member_table] set mb_9 = '$point_acum' where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 따라 회원 등급 바꾸기
if(!$is_admin){
if($point_acum >= 0 && $point_acum < 1500){
$new_level = 6;
}elseif($point_acum >= 1500 && $point_acum < 5000){
$new_level = 7;
}
$squery = ", mb_level = '$new_level'";
}
return $result;
}
common.lib.php 의 일부분인데요.
포인트가 올라가면 여분필드9에 -값을 제외한 +값만 누적되어 자동으로 기록이됩니다.
그 여분필드9에 있는값을 비교하여 조건이 만족하면 자동으로 레벨을 변경하려 하는데
누적되기까지는 잘 되는데 레벨이 변경이 안되는군요...
분명히 어딘가 잘못된거 같은데 까막눈인 저로서는 여기까지 한것만해도 기적같은 수준이라....
고수분들 제발 도와주세요 ㅜㅜ
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='')
{
global $config;
global $g4;
global $is_admin;
// 포인트 사용을 하지 않는다면 return
if (!$config[cf_use_point]) { return 0; }
// 포인트가 없다면 업데이트 할 필요 없음
if ($point == 0) { return 0; }
// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == "") { return 0; }
$mb = sql_fetch(" select mb_id from $g4[member_table] where mb_id = '$mb_id' ");
if (!$mb[mb_id]) { return 0; }
// 이미 등록된 내역이라면 건너뜀
if ($rel_table || $rel_id || $rel_action)
{
$sql = " select count(*) as cnt from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ";
$row = sql_fetch($sql);
if ($row[cnt])
return -1;
}
// 포인트 건별 생성
$sql = " insert into $g4[point_table]
set mb_id = '$mb_id',
po_datetime = '$g4[time_ymdhis]',
po_content = '".addslashes($content)."',
po_point = '$point',
po_rel_table = '$rel_table',
po_rel_id = '$rel_id',
po_rel_action = '$rel_action' ";
sql_query($sql);
// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];
// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 누적의 합을 구하고
$sql = " select sum(if(po_point>0,po_point,0)) as sum_po_point from $g4[point_table] where mb_id='$mb_id'";
$row = sql_fetch($sql);
$point_acum = $row[sum_po_point];
// 포인트 mb_9 에 UPDATE//
$sql = " update $g4[member_table] set mb_9 = '$point_acum' where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 따라 회원 등급 바꾸기
if(!$is_admin){
if($point_acum >= 0 && $point_acum < 1500){
$new_level = 6;
}elseif($point_acum >= 1500 && $point_acum < 5000){
$new_level = 7;
}
$squery = ", mb_level = '$new_level'";
}
return 1;
}
// 포인트 삭제
function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
{
global $g4;
$result = false;
if ($rel_table || $rel_id || $rel_action)
{
$result = sql_query(" delete from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and po_rel_action = '$rel_action' ", false);
// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];
// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
}
// 포인트 누적의 합을 구하고
$sql = " select sum(if(po_point>0,po_point,0)) as sum_po_point from $g4[point_table] where mb_id='$mb_id'";
$row = sql_fetch($sql);
$point_acum = $row[sum_po_point];
// 포인트 mb_9 에 UPDATE//
$sql = " update $g4[member_table] set mb_9 = '$point_acum' where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트 따라 회원 등급 바꾸기
if(!$is_admin){
if($point_acum >= 0 && $point_acum < 1500){
$new_level = 6;
}elseif($point_acum >= 1500 && $point_acum < 5000){
$new_level = 7;
}
$squery = ", mb_level = '$new_level'";
}
return $result;
}
common.lib.php 의 일부분인데요.
포인트가 올라가면 여분필드9에 -값을 제외한 +값만 누적되어 자동으로 기록이됩니다.
그 여분필드9에 있는값을 비교하여 조건이 만족하면 자동으로 레벨을 변경하려 하는데
누적되기까지는 잘 되는데 레벨이 변경이 안되는군요...
분명히 어딘가 잘못된거 같은데 까막눈인 저로서는 여기까지 한것만해도 기적같은 수준이라....
고수분들 제발 도와주세요 ㅜㅜ
댓글 전체

// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
이거를 return 바로 위로 내리시면 될것 같네요.
쿼리 날리는 걸 가장 마지막에 하셔야겠지요.
$squery라는 장바구니(변수)에 , mb_level = '$new_level'를 담고 나서 계산(쿼리 날리기)을 해야지,
계산 먼저 하고 장바구니에 담아봤자 집에 오면 그게 없는 거죵.
$sql = " update $g4[member_table] set mb_point = '$sum_point' $squery where mb_id = '$mb_id' ";
sql_query($sql);
이거를 return 바로 위로 내리시면 될것 같네요.
쿼리 날리는 걸 가장 마지막에 하셔야겠지요.
$squery라는 장바구니(변수)에 , mb_level = '$new_level'를 담고 나서 계산(쿼리 날리기)을 해야지,
계산 먼저 하고 장바구니에 담아봤자 집에 오면 그게 없는 거죵.

답변 감사합니당.덕분에 해결했어요~~
자세한 설명까지 ㅜㅜ 감사합니다~~~~~
자세한 설명까지 ㅜㅜ 감사합니다~~~~~