버튼 클릭시 포인트 차감 (특정 페이지)
본문
category_code 의 링크를 누를때마다
클릭시 포인트가 충분하면 포인트가 -100 씩 차감해서
category 내용을 출력하고
만약 포인트가 부족하면 " 포인트가 부족합니다" 라고 category 내용 출력이 안되게
아래 코드를 수정하고싶습니다.
q/a 이것저것 넣어봤는데 해결이 안되어 문의 드립니다.
어떻게 수정해야 하나요?
<div class="item_category">
<ul>
<?php
$sql = "select * from category where use_yn = 'y' order by nm asc";
$res = sql_query($sql);
while($row = sql_fetch_array($res)){
?>
<li><a href="?category_code=<?php echo $row["category_code"] ?>&n=<?php echo $row["number"] ?>" class="<?php if ($row["category_code"]==$category_code) echo "on"; ?>"><?php echo $row["nm"] ?></a></li>
<?php
}
?>
</ul>
</div>
<div class="item_pool">
<?php if (!$category_code && !$number){?>
<span class="nonselect">카테고리를 선택해주세요. 클릭시 100포인트가 차감됩니다.</span>
<?php }else{?>
!-->
답변 2
한번 차감 후에도 링크 클릭할 때마다 차감한다면
<?php
if( $member['mb_point'] >=100 && $wk && $category_code ) insert_point($member['mb_id'] , -100, '차감', G5_TIME_YMDHIS); //100포인트 차감하기
?>
~~~~
while($row = sql_fetch_array($res)){
if( $member['mb_point'] >= 100)
$url ="?category_code={$row["category_code"]}&n={$row["number"]}&wk=1";
else $url="javascript:alert('포인트 부족');void(0);";
?>
<li><a href="<?php echo $url?>" class="<?php if ($row["category_code"]==$category_code) echo "on"; ?>"><?php echo $row["nm"] ?></a></li>
category list하고
category view 페이지하고 파일을 분리해서 작업하시는 것이 수월하지 않을까요?
포인트 처리는
lib/common.lib.php에
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='', $expire=0)
함수를 이용하시면 됩니다.
답변을 작성하시기 전에 로그인 해주세요.