네이버 별보양 평점주기 구현 정보
네이버 별보양 평점주기 구현첨부파일
본문
원페이지에서 별안나올때 <iframe src="<?=$board_skin_path?>/documentation.html?bo_table=<?=$bo_table?>" height="30" width="150" frameborder=0 scrolling=no ></iframe>
아이프레임 사용하기
------------------------------documentation.html--------------------------
<!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" xml:lang="en" lang="en">
<head>
<title>jQuery Star Rating Plugin v4.11 (2013-03-14)</title>
<!--// plugin-specific resources //-->
<script src='jquery.js' type="text/javascript"></script>
<script src='jquery.MetaData.js' type="text/javascript" language="javascript"></script>
<script src='jquery.rating.js' type="text/javascript" language="javascript"></script>
<link href='jquery.rating.css' type="text/css" rel="stylesheet"/>
<!--// documentation resources //-->
<!--<script src="http://code.jquery.com/jquery-migrate-1.1.1.js" type="text/javascript"></script>-->
<link type="text/css" href="/@/js/jquery/ui/jquery.ui.css" rel="stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js" type="text/javascript"></script>
<link href='documentation/documentation.css' type="text/css" rel="stylesheet"/>
<script src='documentation/documentation.js' type="text/javascript"></script>
</head>
<body>
<script>
$(function(){
$('.auto-submit-star').rating({
callback: function(value, link){
// 'this' is the hidden form element holding the current value
// 'value' is the value selected
// 'element' points to the link element that received the click.
//alert(value);
// To submit the form automatically:
//this.form.submit();
// To submit the form via ajax:
//$(this.form).ajaxSubmit();
$.post("__m3rating_update.php", {
star :value,
bo_table: $("input[name=bo_table]").val()
}, function(data){
$("#result").html(data)
});
}
});
});
</script>
<span id="result"></span>
<input type="hidden" name="bo_table" value="<?=$_REQUEST[bo_table]?>" >
<input class="auto-submit-star required" type="radio" name="test-3A-rating-1" id="test" value="1"/>
<input class="auto-submit-star" type="radio" name="test-3A-rating-1" value="2"/>
<input class="auto-submit-star" type="radio" name="test-3A-rating-1" value="3"/>
<input class="auto-submit-star" type="radio" name="test-3A-rating-1" value="4"/>
<input class="auto-submit-star" type="radio" name="test-3A-rating-1" value="5"/>
---------------------------------------------------------------------------------------------------------------
__m3rating_update.php
---------------------------------------------------------------------------------------------------------------
<?
// 기본 인클루드
$g4_path = "../../..";
include_once("$g4_path/common.php");
$s_id = session_id();
//print_r($_POST);
// 변수 처리
$gr_id = $_POST[gr_id];
$bo_table = $_POST[bo_table];
//$wr_id = $_POST[wr_id];
$star = $_POST[star];
if($member[mb_id]) $mb_id = $member[mb_id];
else $mb_id = $_SERVER[REMOTE_ADDR];
// 내 글이면
$s_name = "자신의 글은 추천할 수 없습니다.";
if($write[mb_id]==$mb_id || $write[wr_ip]==$mb_id) die($s_name);
//if($write[mb_id]==$mb_id || $write[wr_ip]==$mb_id) die("자신의 글은 추천할 수 없습니다.");
// 기존 별점 가져오기
$sql = "select * from m3rating where bo_table='$bo_table'";
$rating = sql_fetch($sql);
// 기존 별점 있으면
if($rating) {
// 이미 참가한 경우
//$s_name_alert = "이미 점수를 주셨습니다";
//if(strpos(",".$rating[star_list].",", ",".$mb_id.",")!==false) die($s_name_alert);
// 참가하지 않은 경우 별점을 추가한다.
//$star_average = (array_sum(explode(",",$rating[star_data]))+$star)/(sizeof(explode(",",$rating[star_data]))+1);
$sql = "update m3rating set bo_table='$bo_table', wr_id='$wr_id', star_average='$star_average', star_data='$star', star_list='$mb_id', s_id = '$s_id' where bo_table='$bo_table' ";
}
// 기존 별점이 없으면
else {
$sql = "insert into m3rating set gr_id='$gr_id', bo_table='$bo_table', wr_id='$wr_id', star_average='$star', star_data='$star', star_list = '', s_id = '$s_id'";
}
// 실행하기
sql_query($sql);
//echo $sql."/sql<br>";
// 완료
$s_name_end = "{$star}점이 반영되었습니다";
//echo $s_name_end."<br>";
?>
1