<% else ' if the user did input a choice on the vote/ballot ' check to see if their ip address is already in the db accessdb="votes_db" cn="driver={Microsoft Access Driver (*.mdb)};" cn=cn & "dbq=" & server.mappath(accessdb) set rs = server.createobject("ADODB.Recordset") sql = "select ip from ballot where ip ='" & u_ip & "'" rs.Open sql, cn if rs.eof then ' if the user has not voted previously indicate it been_here_before="No" end if rs.close if been_here_before = "No" then ' Since the user has not voted previously their input ' their vote will be added to the db sql = "insert into ballot (ip, selection" & u_input &") " sql = sql & "values ('" & u_ip & "',1)" rs.Open sql, cn end if 'This will summerize and count the records in the db sql= "select distinctrow sum(selection1) as sum_selection1, " sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, " sql= sql & "sum(selection4) AS sum_selection4, count(*) AS total_votes " sql= sql & "FROM ballot;" rs.Open sql, cn total1=rs ("sum_selection1") total2=rs ("sum_selection2") total3=rs ("sum_selection3") total4=rs ("sum_selection4") tota15=rs ("sum_selection5") count=rs ("total_votes") %>
1 14%
2 25%
3 4%
4 12%
5 45%
<%= formatnumber((total4/count)*100,1) %>%
Total Votes: 1,000
1