<%
did=request("did")
Dim tp,tt,tr,prs
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open "Select * from question where did="&did,conn,1,1
If not(rs.eof and rs.bof) Then
Do while not rs.eof
tp=split(Trim(Request.Form(""&rs("id")&""))&",",",")
For tt=0 to Ubound(tp)-1
If tp(tt)<>"" Then
Set prs=Server.CreateObject("ADODB.RecordSet")
prs.open "Select ps from answer where id="&tp(tt),conn,1,3
prs("ps")=prs("ps")+1
prs.update
prs.close
Set prs=nothing
End If
Next
tr=Replace(Request.Form(""&rs("id")&"")," ","")
tr=Replace(tr,",","")
If tr<>"" Then
conn.execute("update question set ucounts=ucounts+1 where id="&rs("id"))
End If
rs.MoveNext
Loop
End If
rs.close
Set rs=nothing
%>
參考答案:<%
did=request("did")
Dim tp,tt,tr,prs
Set rs=Server.CreateObject("ADODB.RecordSet") 建立数据库连接
rs.open "Select * from question where did="&did,conn,1,1 打开数据为QUESTION的数据表
If not(rs.eof and rs.bof) Then 判断是游标是不否指在最后或最前
Do while not rs.eof 如果游标不是指在最后
tp=split(Trim(Request.Form(""&rs("id")&""))&",",",") 把得到的ID值按","为界线存入数组tp
For tt=0 to Ubound(tp)-1 循环T从最小下标到最大下标
If tp(tt)<>"" Then 如果TP数组中的值不为“SPACE”
Set prs=Server.CreateObject("ADODB.RecordSet")
prs.open "Select ps from answer where id="&tp(tt),conn,1,3
prs("ps")=prs("ps")+1 那么在数据表ANSWER中的PS值加1
prs.update 更新数据表ANSWER
prs.close 关闭数据连接
Set prs=nothing 清空缓存
End If
Next 和FOR是构成循环
tr=Replace(Request.Form(""&rs("id")&"")," ","")
tr=Replace(tr,",","") 用中文状态输入的“,” 替换成英文状态的“,”
If tr<>"" Then
conn.execute("update question set ucounts=ucounts+1 where id="&rs("id")) 更新皓号里面的语句当ID=RS(“iD”)值时UCOUNTS值自动加1
End If
rs.MoveNext 游标自动下移
Loop 和WHILE构成打循环语句
End If
rs.close 关闭数据连接
Set rs=nothing 清空缓存
%>