<% option explicit Response.Buffer = False Response.CacheControl = "private" Dim intQuestionId Dim intChoiceId Dim sqlrecordvote Dim BlnCheck Dim strConnection Dim conn Dim vote_cookie Dim Bnlvote Dim SqlSelectVoteQuestion Dim adoQuestion Dim strVoteQuestion Dim SqlChoice Dim adoChoice Dim strChoices Dim sqlStats Dim adoStats Dim count Dim total Dim result Dim sum Dim sqlChoiceCount Dim intCount Dim adoCount count = 0 Bnlvote="" 'Live strConnection = "Driver={MySQL ODBC 3.51 Driver}; Server=dedi48.flk1.host-h.net; Database=voiceofthecape; UID=vocfma_1; PWD=MJHEufA5; Option=3" 'Localhost 'strConnection = "Driver={MySQL ODBC 3.51 Driver}; Server=dedi48.flk1.host-h.net; Database=voiceofthecape; UID=; PWD=; Option=3" Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open(strConnection) intQuestionId = trim(Request.QueryString("intQuestionId")) intChoiceId = trim(Request.QueryString("intChoiceId")) Sub Display_Poll_Ouestion() SqlSelectVoteQuestion = "select * from vote_questions as a where a.voteid = " & intQuestionId & " LIMIT 0,1;" Set adoQuestion = Conn.Execute(SqlSelectVoteQuestion) If not adoQuestion.EOF then strVoteQuestion = adoQuestion("VoteQuestion") end if adoQuestion.Close() set adoQuestion = nothing End sub call Display_Poll_Ouestion sqlChoiceCount = "select count(choiceid) as total from vote_responses where questionid = " &intQuestionId & "" Set adoCount = Conn.Execute(sqlChoiceCount) If not adoCount.eof then intCount = adoCount("total") Else intCount = 0 End if adoCount.close set adoCount =nothing Sub Generate_vote_stats(intchoiceId) result = 0 sqlStats = "select count(questionid) as total, choiceid from vote_responses where choiceid = " & intChoiceId & " group by choiceid, questionid;" Set adoStats = Conn.Execute(sqlStats) If not adoStats.eof then Result = round(((adoStats("total")/intCount ) * 100),1) End If adoStats.close set adoStats = nothing End sub %>
<%=strVoteQuestion%>
<% SqlChoice = "select a.*" SqlChoice = SqlChoice & " from vote_choices as a " SqlChoice = SqlChoice & "where a.voteId = "& trim(intQuestionId) &"" set adoChoice = Conn.Execute(SqlChoice) %>
<% If not adoChoice.EOF Then While not adoChoice.eof strChoices = adoChoice("choice") call Generate_vote_stats(adoChoice("id")) %> <% adoChoice.movenext Wend End if adoChoice.close set adoChoice =nothing %>
>   <%=strChoices%>
<%=Result%>%
  RESULTS CLOSE 
<% Conn.Close set conn = nothing %>