Statistics | voting | Original <!--
Save chapter of the multi-question voting statistic system
Author: Cheery_ke Version: 1.0
Support: asp+access WINDOWS2000 PRO + IIS5.0 test passed
Disadvantage: Each question and the database Exchange data once, the action is bigger, does not apply to the question of many questions to vote (>20? )
Advantages: The use of a data table, operation, statistics are relatively simple
—————— data table Structure ——————
In this case, the database name is 111.MDB and the table name is 111
The topic number is the field value, plus one ID, the total number of questions + 1 fields
The result flag is the ID value of each record, that is, a total of a,b,c,d,e ... Record
-->
<% @LANGUAGE =vbscript%>
<%on ERROR RESUME next%>
<%
' Define a database connection
SET Conn=server. CreateObject ("ADODB.") CONNECTION ")
Dbpath=server. MapPath ("111.MDB")
CONN. Open "Driver={microsoft Access DRIVER (*.mdb)};d bq=" &dbpath
' Define array myarray (x), where x is the number of topics +1
DIM MyArray (6)
MyArray (0) = ""
MyArray (1) =request ("R1")
MyArray (2) =request ("R2")
MyArray (3) =request ("R3")
MyArray (4) =request ("R4")
MyArray (5) =request ("R5")
' Define loop variable i
I=1
' Declare i> the number of questions to exit the loop
Do as not i>5
' Define RS
SET Rs=server. CreateObject ("ADODB.") RECORDSET ")
' Define SQL variable, S ' &I& ' is the title number, ID is the result
Sql= "UPDATE SET S" &I& "=s" &I& "+1 WHERE id= '" &myarray (I) & "'"
Rs. Open sql,conn,3,2
' Release RS and SQL variables
SET rs=nothing
SET sql=nothing
I=i+1
LOOP
Response.Write ("<center><br><br>saved YOUR VOTE succed!! </CENTER> ")
Response.Write ERR. DESCRIPTION
%>