네이버 별보양 평점주기 구현
원페이지에서 별안나올때 <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개
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4402 | ||
| 2034 | 3년 전 | 4243 | ||
| 2033 | 3년 전 | 2949 | ||
| 2032 | 3년 전 | 3203 | ||
| 2031 | 3년 전 | 2736 | ||
| 2030 |
|
3년 전 | 2926 | |
| 2029 | 3년 전 | 4549 | ||
| 2028 |
|
3년 전 | 2241 | |
| 2027 | 3년 전 | 3833 | ||
| 2026 | 3년 전 | 2925 | ||
| 2025 | 3년 전 | 3045 | ||
| 2024 |
유레카56
|
3년 전 | 2313 | |
| 2023 |
sIr어드밈
|
3년 전 | 3032 | |
| 2022 | 3년 전 | 3810 | ||
| 2021 | 3년 전 | 3209 | ||
| 2020 | 3년 전 | 2871 | ||
| 2019 | 3년 전 | 5118 | ||
| 2018 | 3년 전 | 3682 | ||
| 2017 | 3년 전 | 3609 | ||
| 2016 | 3년 전 | 5483 | ||
| 2015 | 3년 전 | 3646 | ||
| 2014 | 3년 전 | 3467 | ||
| 2013 | 3년 전 | 2653 | ||
| 2012 | 3년 전 | 3067 | ||
| 2011 | 3년 전 | 4261 | ||
| 2010 |
sIr어드민
|
3년 전 | 2313 | |
| 2009 | 3년 전 | 3565 | ||
| 2008 |
|
3년 전 | 2414 | |
| 2007 |
|
3년 전 | 2276 | |
| 2006 |
|
3년 전 | 2897 | |
| 2005 | 3년 전 | 4383 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기