본문 바로가기

프로그래밍

ASP - 최근본 상품

출처 : http://menote.tistory.com 

 <%
    '########### 최근 본 상품 쿠키에 담기 ################
    pdtViewSize = 4  //보여질개수
    pdtViewTemp = ""
    pdtViewList = request.cookies("pdtViewList") '본 내역을 문자열로받는다.
    pdtViewArray= split(trim(pdtViewList), ",")  '본 내역이 여러개 있으니, 콤마로 구분하여 배열 생성
    pdtViewExist=false '이미 존재하는 지 확인하는 플래그

    for i = 0 to ubound(pdtViewArray)
        if pdtViewArray(i) = pdt_cd then '넣을려구 했는데 리스트에 이미 있으면 존재하는걸로 표시
            pdtViewExist=true
        end if
    Next
   
    '본게 리스트에 없으면, 추가해준다. 없으면 추가해줘야지 안그러면 똑같은 거 볼때마다 들어간다.
    if not pdtViewExist Then   
        for i = 0 to ubound(pdtViewArray)
            if i < pdtViewSize-1 then
                pdtViewTemp = pdtViewTemp&","&pdtViewArray(i)
            end if
        next
        pdtViewList = pdt_cd & pdtViewTemp
        response.cookies("pdtViewList")=pdtViewList

    end If
    '############ //최근 본 상품 쿠키에 담기 ###################
%>
<table border="0" cellpadding="0" cellspacing="0">
<%
    '############ 최근 본 상품 쿠키에 보여주기 ###################
    pdtViewList = request.cookies("pdtViewList") ' 이 루틴은 단순히 쿠키에 있는걸 뿌려주는 단순 루틴
    pdtViewArray= split(trim(pdtViewList), ",")

    for i = 0 to ubound(pdtViewArray)
        If i<=3 then
    '     select * from 상품 where 상품코드=pdtViewArray(i)
%>
            <tr>
                <td height="40" align="center">
                    <table width="30" height="30" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td><%=pdtViewArray(i)%><img src="../Img/new/main/ex_img.gif" width="30" height="30"></td>
                        </tr>
                    </table>
                </td>
            </tr>

<%
        End if
    Next

    For j=i+1 To 3
%>
            <tr>
                <td height="40" align="center">
                    <table width="30" height="30" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>

<%
    next
%>
</table>


2008년 10월 10일 10시 07분 00초,     조회수 : 243
  제목 : [오늘 본 상품] 부탁드리겠습니다.
SEQ : 150427 글쓴이 : choihcpd
작성 포맷 : TEXT 모드, 자동 줄바꿈 사용

'오늘본상품 저장   

ToDayGoodsSet SG_CODE, SG_IMG '함수호출 상품코드, 상품이미지   

Sub ToDayGoodsSet(SG_CODE,SG_IMG)     
 C_Goods = Request.Cookies("TodayGcode")        ( 1 )
 C_Count = Request.Cookies("TodayGcode").count  ( 2 )   
 If C_Goods = "" OR C_Count = "" Then
  C_Count = 0     
 If C_Count > 19 Then
  C_Count = 19 '20개까지 저장을 의미           
 If InStr(C_Goods, "=" & SG_CODE) = 0 Then '저장된게 없으면 기존것은 배열에서 1씩 뒤로저장        
  For c_cnt = C_Count To 1 Step -1           
  
(3)Response.Cookies("TodayGcode")("G" & c_cnt + 1) = Request.Cookies("TodayGcode")("G" & c_cnt)    
(4)Response.Cookies("TodayImg")("G" & c_cnt + 1) = Request.Cookies("TodayImg")("G" & c_cnt)        
  next              
  '첫번째 배열에 신규상품 저장        
  Response.Cookies("TodayGcode")("G1") = SG_CODE        
  Response.Cookies("TodayImg")("G1") = SG_IMG     
 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")  
End Sub
------------------------------------------------------------------------------------------------   
'오늘본상품보기   

 T_Goods = Request.Cookies("TodayGcode")  
 T_Count = Request.Cookies("TodayGcode").count  
 If T_Goods = "" OR T_Count = "" Then
  T_Count = 0  
 If T_Count > 20 Then
  T_Count = 20   
  For g_cnt = 1 To T_Count     
   TodayGcode = Request.Cookies("TodayGcode")("G" & g_cnt)     
   TodayImg = Request.Cookies("TodayImg")("G" & g_cnt)           
   response.write TodayGcode & "<br>"  
  Next

'프로그래밍' 카테고리의 다른 글

ASP - 내장함수  (0) 2011.08.17
ASP - 날짜 함수  (0) 2011.08.17
ASP - 쿠키 유지기간 설정  (0) 2011.08.17
CSS - 백그라운드 반복 Repeat  (0) 2011.08.17
CSS - 투명도 filter:alpha(opacity=0);  (0) 2011.08.17