My Name is Kay....

DIY , 먹방 , 개발 , 육아 , 여행 좋아합니다.
AdBlock 사용시 화면이 정상적으로 노출되지 않습니다.
포스팅 관련 문의 및 개발 문의는 Email : wkzkfmxksi@gmail.com

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
kay
조회 수 4325 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

오늘 본 상품 쿠키로 처리하기 입니다.

아래 원문의 게시물을 참고하여 수정하였습니다.


1. 우선 저장하기


<%
		'오늘본상품 저장
		Sub ToDayGoodsSet(SG_CODE,SG_IMG,SG_URL)
			C_Goods = Request.Cookies("TodayGcode")
			C_Count = Request.Cookies("TodayGcode").count
			If C_Goods = "" OR C_Count = "" Then C_Count = 0
			If C_Count > 99 Then C_Count = 99 '100개까지 저장을 의미

			For c_cnt = 1 To C_Count Step 1  ' 중복 데이터 체크하여 추가 안함.
				If Request.Cookies("TodayGcode")("G" & c_cnt) = SG_CODE Then
					Exit sub
				End If
			Next

			If InStr(C_Goods, "=" & SG_CODE) = 0 Then '저장된게 없으면 기존것은 배열에서 1씩 뒤로저장
				For c_cnt = C_Count To 1 Step -1
				Response.Cookies("TodayGcode")("G" & c_cnt + 1) = Request.Cookies("TodayGcode")("G" & c_cnt)
				Response.Cookies("TodayImg")("G" & c_cnt + 1) = Request.Cookies("TodayImg")("G" & c_cnt)
				Response.Cookies("TodayUrl")("G" & c_cnt + 1) = Request.Cookies("TodayUrl")("G" & c_cnt)
				Next

				'첫번째 배열에 신규상품 저장
				Response.Cookies("TodayGcode")("G1") = SG_CODE
				Response.Cookies("TodayImg")("G1") = SG_IMG
				Response.Cookies("TodayUrl")("G1") = SG_URL
			End If

			'쿠기 expires(만기)일 및 사용허용 도메인설정 만기일설정은 1일로 함
			NewDate = DateAdd("d", 1, Now())
			Response.Cookies("TodayGcode").expires = NewDate
			Response.Cookies("TodayGcode").path = "/"
			Response.Cookies("TodayGcode").Domain = Request.SERVERVARIABLES("SERVER_NAME")
			Response.Cookies("TodayImg").expires = NewDate
			Response.Cookies("TodayImg").path = "/"
			Response.Cookies("TodayImg").Domain = Request.SERVERVARIABLES("SERVER_NAME")
			Response.Cookies("TodayUrl").expires = NewDate
			Response.Cookies("TodayUrl").path = "/"
			Response.Cookies("TodayUrl").Domain = Request.SERVERVARIABLES("SERVER_NAME")
		End Sub

		ToDayGoodsSet productCode, Rs("postUrl") , Request.SERVERVARIABLES("HTTP_URL")   '함수호출 상품코드, 상품이미지
%>



2.저장된 상품 노출하기


<%
T_Goods = Request.Cookies("TodayGcode")
T_Count = Request.Cookies("TodayGcode").count  
If T_Goods = "" OR T_Count = "" Then T_Count = 0
If T_Count > 99 Then T_Count = 99   

If T_Count / 4 <= 1 Then
	T_Count_page = 1
Else
	If CInt(T_Count mod 4) = 0 Then
		T_Count_page =  CInt(T_Count / 4)
	Else
		T_Count_page =  CInt(T_Count / 4) + 1
	End If
End If

%>
<div class="head">
오늘 본<br />상품(<%=T_Count%>)
</div>
<%
   For g_cnt = 1 To 4 ' 4개까지 노출
	  TodayGcode = Request.Cookies("TodayGcode")("G" & g_cnt)
	  TodayImg = Request.Cookies("TodayImg")("G" & g_cnt)
	  TodayUrl = Request.Cookies("TodayUrl")("G" & g_cnt)

	  %>
	  <a href="<%=TodayUrl%>"><img src="<%=TodayImg%>" onError="this.src='/images/noimage.png';" /></a>
	  <%
   Next
%>
<div style="text-align:center;"><a href="#"><span style="float:left;padding:6px;padding-top:0;">◀</span></a>1/<%=T_Count_page%><a href="Javascript:fnGetTodayGoods(2);"><span style="float:right;padding:6px;padding-top:0;">▶</span></a></div>



3.1. 페이징 처리하기 


<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
<!--
	function fnGetTodayGoods(page)
	{
		$.ajax({
			type: "POST",
			dataType: "html",
			url: "/productProc.asp",
			data: { mode : "TODAYGOODS" , page : page },
			success: function(toDayGoods){
				$("#historybanner").html(toDayGoods);
			}
			,error: function(){ 
				
			}
		});   
	}
//-->
</script>



3.2. 페이징 처리하기


<%
If mode = "TODAYGOODS" Then
	page	= Request("page")
	T_Goods = Request.Cookies("TodayGcode")
	T_Count = Request.Cookies("TodayGcode").count
	If T_Goods = "" OR T_Count = "" Then T_Count = 0
	If T_Count > 99 Then T_Count = 99

	If T_Count / 4 <= 1 Then
		T_Count_page = 1
	Else
		T_Count_page = CInt(T_Count / 4) + 1
	End If

	fromCount = (page*4) - 3
	toCount = page * 4

	nextPage = page+1
	If nextPage > T_Count_page Then nextPage = T_Count_page
	prePage = page - 1
	If prePage < 1 Then prePage = 1

	%>
	<div class="head">
	오늘 본<br />상품(<%=T_Count%>)
	</div>
	<%
	   For g_cnt = fromCount  To toCount
		  TodayGcode = Request.Cookies("TodayGcode")("G" & g_cnt)
		  TodayImg = Request.Cookies("TodayImg")("G" & g_cnt)
		  TodayUrl = Request.Cookies("TodayUrl")("G" & g_cnt)
		  If TodayUrl = "" Then TodayUrl = "#"

		  %>
		  <a href="<%=TodayUrl%>"><img src="<%=TodayImg%>" onError="this.src='/images/noimage.png';" /></a>
		  <%
	   Next
	%>
	<div style="text-align:center;"><a href="Javascript:fnGetTodayGoods(<%=prePage%>);"><span style="float:left;padding:6px;padding-top:0;">◀</span></a><%=page%>/<%=T_Count_page%><a href="Javascript:fnGetTodayGoods(<%=nextPage%>);"><span style="float:right;padding:6px;padding-top:0;">▶</span></a></div>
	<%
End If
%>


원문 Url : http://www.taeyo.net/Forum/Content.aspx?SEQ=144037&TBL=ASP ( jimmy 님 게시물 )

?