채택완료

추천 비추천 기능에서 취소기능은 없나요..?ㅠㅠ

추천 비추천을 한 글에서 다시 취소를 하는 방법은 없는걸까요..?

구현하는 방법좀 알려주시면 감사하겠습니다..ㅠㅠ

 

Copy
<?phpinclude_once('./_common.php'); @include_once($board_skin_path.'/good.head.skin.php'); // 자바스크립트 사용가능할 때if($_POST['js'] == "on") {    $error = $count = "";     function print_result($error, $count)    {        echo '{ "error": "' . $error . '", "count": "' . $count . '" }';        if($error)            exit;    }     if (!$is_member)    {        $error = '회원만 가능합니다.';        print_result($error, $count);    }     if (!($bo_table && $wr_id)) {        $error = '값이 제대로 넘어오지 않았습니다.';        print_result($error, $count);    }     $ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;    if (!get_session($ss_name)) {        $error = '해당 게시물에서만 추천 또는 비추천 하실 수 있습니다.';        print_result($error, $count);    }     $row = sql_fetch(" select count(*) as cnt from {$g5['write_prefix']}{$bo_table} ", FALSE);    if (!$row['cnt']) {        $error = '존재하는 게시판이 아닙니다.';        print_result($error, $count);    }     if ($good == 'good' || $good == 'nogood')    {        if($write['mb_id'] == $member['mb_id']) {            $error = '자신의 글에는 추천 또는 비추천 하실 수 없습니다.';            print_result($error, $count);        }         if (!$board['bo_use_good'] && $good == 'good') {            $error = '이 게시판은 추천 기능을 사용하지 않습니다.';            print_result($error, $count);        }         if (!$board['bo_use_nogood'] && $good == 'nogood') {            $error = '이 게시판은 비추천 기능을 사용하지 않습니다.';            print_result($error, $count);        }         $sql = " select bg_flag from {$g5['board_good_table']}                    where bo_table = '{$bo_table}'                    and wr_id = '{$wr_id}'                    and mb_id = '{$member['mb_id']}'                    and bg_flag in ('good', 'nogood') ";        $row = sql_fetch($sql);        if ($row['bg_flag'])        {            if ($row['bg_flag'] == 'good')                $status = '추천';            else                $status = '비추천';             $error = "이미 $status 하신 글 입니다.";            print_result($error, $count);        }        else        {            // 추천(찬성), 비추천(반대) 카운트 증가            sql_query(" update {$g5['write_prefix']}{$bo_table} set wr_{$good} = wr_{$good} + 1 where wr_id = '{$wr_id}' ");            // 내역 생성            sql_query(" insert {$g5['board_good_table']} set bo_table = '{$bo_table}', wr_id = '{$wr_id}', mb_id = '{$member['mb_id']}', bg_flag = '{$good}', bg_datetime = '".G5_TIME_YMDHIS."' ");             $sql = " select wr_{$good} as count from {$g5['write_prefix']}{$bo_table} where wr_id = '$wr_id' ";            $row = sql_fetch($sql);             $count = $row['count'];             print_result($error, $count);        }    }} else {    include_once(G5_PATH.'/head.sub.php');     if (!$is_member)    {        $href = './login.php?'.$qstr.'&amp;url='.urlencode('./board.php?bo_table='.$bo_table.'&amp;wr_id='.$wr_id);         alert('회원만 가능합니다.', $href);    }     if (!($bo_table && $wr_id))        alert('값이 제대로 넘어오지 않았습니다.');     $ss_name = 'ss_view_'.$bo_table.'_'.$wr_id;    if (!get_session($ss_name))        alert('해당 게시물에서만 추천 또는 비추천 하실 수 있습니다.');     $row = sql_fetch(" select count(*) as cnt from {$g5['write_prefix']}{$bo_table} ", FALSE);    if (!$row['cnt'])        alert('존재하는 게시판이 아닙니다.');     if ($good == 'good' || $good == 'nogood')    {        if($write['mb_id'] == $member['mb_id'])            alert('자신의 글에는 추천 또는 비추천 하실 수 없습니다.');         if (!$board['bo_use_good'] && $good == 'good')            alert('이 게시판은 추천 기능을 사용하지 않습니다.');         if (!$board['bo_use_nogood'] && $good == 'nogood')            alert('이 게시판은 비추천 기능을 사용하지 않습니다.');         $sql = " select bg_flag from {$g5['board_good_table']}                    where bo_table = '{$bo_table}'                    and wr_id = '{$wr_id}'                    and mb_id = '{$member['mb_id']}'                    and bg_flag in ('good', 'nogood') ";        $row = sql_fetch($sql);        if ($row['bg_flag'])        {            if ($row['bg_flag'] == 'good')                $status = '추천';            else                $status = '비추천';             alert("이미 $status 하신 글 입니다.");        }        else        {            // 추천(찬성), 비추천(반대) 카운트 증가            sql_query(" update {$g5['write_prefix']}{$bo_table} set wr_{$good} = wr_{$good} + 1 where wr_id = '{$wr_id}' ");            // 내역 생성            sql_query(" insert {$g5['board_good_table']} set bo_table = '{$bo_table}', wr_id = '{$wr_id}', mb_id = '{$member['mb_id']}', bg_flag = '{$good}', bg_datetime = '".G5_TIME_YMDHIS."' ");             if ($good == 'good')                $status = '추천';            else                $status = '비추천';             $href = './board.php?bo_table='.$bo_table.'&amp;wr_id='.$wr_id;             alert("이 글을 $status 하셨습니다.", '', false);        }    }} @include_once($board_skin_path.'/good.tail.skin.php');?>

 

good.php 소스입니다 ㅠㅠ 도와주세요..!

답변 1개

채택된 답변
+20 포인트

1. 가장 쉬운 방법은 자기가 추천/비추천한 게시물인지 확인하는 코드를 넣어서

2. 추천버튼 대신 추천취소 / 비추천 대신 비추천취소 버튼을 보이게 해서

3. 버튼 누르면 내역을 삭제하고 카운트도 감소시키는 ajax를 실행하도록 만들면 됩니다

-- ajax를 모르면 그냥 링크로 내역을 삭제하는 화일을 호출해서 작업 후 원래 페이지로 돌아오는 코드를

    마지막에 넣으면 되겠습니다

 

코드를 만들어 놓고 안되는 부분 일부만 수정하는 것이 아니고 기능을 완전히 새로이 만들어 넣는 것이니 

의뢰 게시판으로 가야할 내용 같습니다

 

 

 

답변을 작성하려면 로그인이 필요합니다.

🐛 버그신고