<%
dim dbc,rs,query
shopopendatabase dbc
query = "select TOP 10 * from comment where productid = " & productid & " order by lasttime desc"
set rs = dbc.execute(query)
dim content,ptime,pren,preply
dim n
n=0
Do WHILE not rs.EOF and n<10
content= rs("comment")
ptime = rs("lasttime")
pren = rs("nickname")
preply = rs("reply")
n=n+1
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="text6">
<tr>
<td style="padding-left:20px;padding-right:5px">
<%=content%>
</td>
<td width="60"> <%=ptime%> </td>
<td width="45"> <%=pren%> </td>
</tr>
<%
if (preply<>"") then
%>
<tr>
<td style="padding-left:20px;padding-right:5px">
<font color=red>答复:</font><%=preply %>
</td>
<td width="60">
</td>
<td width="45">
</td>
</tr>
<%
end if
%>
<tr>
<td colspan="3" background='images/topbg.gif' height=3></td>
</tr>
</table>
<%
rs.movenext
Loop
closerecordset rs
shopclosedatabase dbc
%>
例程3-12中的query = "select TOP 10 * from comment where productid = " & productid & " order by lasttime desc"语句,是从数据库comment表中得到相关产品的最后增加的前10条评论(按时间倒顺序排列,然后取前10条)。
<%
dim myaction
dim cartstr,cartnumstr
DimMyProductArray(20), MyNumArray(20),totalnum,MyProductArrayTmp,MyNumArrayTmp
cartstr = getCartFromCookie()
cartnumstr=getCartNumFromCookie()
if (cartstr=NULL or cartstr ="") then
cartstr =""
end if
if (cartnumstr=NULL or cartnumstr ="") then
cartnumstr =""
end if
MyProductArrayTmp = Split(cartstr, ",",-1,1)
MyNumArrayTmp = Split(cartnumstr, ",",-1,1)
'response.write "cartstr=" & cartstr &"<br>"
'response.write "cartnumstr=" & cartnumstr &"<br>"
'response.write "UBound(MyProductArrayTmp)=" &UBound(MyProductArrayTmp) &"<br>"
'response.write "LBound(MyProductArrayTmp)=" &LBound(MyProductArrayTmp) &"<br>"
'response.write "UBound(MyNumArrayTmp=" &UBound(MyNumArrayTmp) &"<br>"
'response.write "LBound(MyNumArrayTmp)=" &LBound(MyNumArrayTmp) &"<br>"
If(UBound(MyProductArrayTmp)<>UBound(MyNumArrayTmp)or LBound(MyProductArrayTmp)<>LBound(MyNumArrayTmp)) then
cartstr =""
cartnumstr =""
setCartToCookie cartstr,cartnumstr,0,0
MyProductArrayTmp = Split(cartstr, ",",-1,1)
MyNumArrayTmp = Split(cartnumstr, ",",-1,1)
end if
dim n
For n =LBound(MyProductArrayTmp) to UBound(MyProductArrayTmp)
MyProductArray(n)=MyProductArrayTmp(n)
MyNumArray(n)=MyNumArrayTmp(n)
Next
totalnum=getCartTotalNumFromCookie()
if (totalnum=NULL or totalnum="") then
totalnum=0
end if
myaction=request("myaction")
dim productidif (myaction="add") then
productid=request("productid")
if (IsValid(productid)) then
if (cartstr=NULL or cartstr ="") then
cartstr=productid
cartnumstr=1
MyProductArray(0)=productid
MyNumArray(0)=1
totalnum=1
else
Dim i,IsExist
IsExist="false"
For i = 0 to CInt(totalnum)-1
if (MyProductArray(i) =productid) then
IsExist="true"
exit for
end if
if (IsExist="true") then
MyNumArray(i)=MyNumArray(i)+1
cartnumstr=""
For i = 0 to CInt(totalnum)-1
if (cartnumstr="") then
cartnumstr=CStr(MyNumArray(0))
else
cartnumstr=CStr(cartnumstr)+","+CStr(MyNumArray(i))
end if
Next
else
cartstr=CStr(cartstr)+","+CStr(productid)
cartnumstr=cartnumstr+",1"
MyProductArray(totalnum)=productid
MyNumArray(totalnum)=1
totalnum=totalnum+1
end if
end if
setCartToCookie cartstr,cartnumstr,totalnum,0
response.redirect("cart.asp")
response.end
else
response.write "增加的产品id不合法!<br>"
end if
else
if(myaction="del") then
productid=request("productid")
if (IsValid(productid)) then
cartstr=""
cartnumstr=""
For i = 0 to CInt(totalnum)-1
if (productid<>MyProductArray(i)) then
if (cartnumstr="") then
cartstr=CStr(MyProductArray(i))
cartnumstr=CStr(MyNumArray(i))
end
cartstr=cartstr+","+CStr(MyProductArray(i))
cartnumstr=CStr(cartnumstr)+","+CStr(MyNumArray(i))
end if
end if
Next
end if
else
if(myaction="update") then
cartstr="update"
else
end if
end if
end ifsetCartToCookie cartstr,cartnumstr,totalnum,0
ShowCart("yes")
%>
<%
dim cartstr
cartstr = getCartFromCookie()
if (cartstr=NULL or cartstr ="") then
response.redirect "Cart.asp"
response.end
end if
dim payName,payPhone,payEmail,payAddress
if (session("userautoid")<=0) then
payName=""
payPhone=""
payEmail=""
payAddress=""
else
dim dbc,query,rs
shopopendatabase dbc
query = "select * from myUser where autoid = " & session("userautoid")
set rs = dbc.execute(query)
Ifrs.EOF ThepayName=rs("realname")payPhone=rs("phone")payEmail=rs("userid")payAddress=rs("Address")end if
closerecordset rs
shopclosedatabase dbc
end if