<% '## Forum_SQL - Get Poll strSql = "SELECT " & strTablePrefix & "TOPICS.answer1, " & strTablePrefix & "TOPICS.count1, " strSql = strSql & strTablePrefix & "TOPICS.answer2, " & strTablePrefix & "TOPICS.count2, " strSql = strSql & strTablePrefix & "TOPICS.answer3, " & strTablePrefix & "TOPICS.count3, " strSql = strSql & strTablePrefix & "TOPICS.answer4, " & strTablePrefix & "TOPICS.count4, " strSql = strSql & strTablePrefix & "TOPICS.answer5, " & strTablePrefix & "TOPICS.count5, " strSql = strSql & strTablePrefix & "TOPICS.answer6, " & strTablePrefix & "TOPICS.count6, " strSql = strSql & strTablePrefix & "TOPICS.answer7, " & strTablePrefix & "TOPICS.count7, " strSql = strSql & strTablePrefix & "TOPICS.answer8, " & strTablePrefix & "TOPICS.count8, " strSql = strSql & strTablePrefix & "TOPICS.T_MESSAGE " strSql = strSql & "FROM " & strTablePrefix & "TOPICS " strSql = strSql & "WHERE " & strTablePrefix & "TOPICS.TOPIC_ID = " & Request.QueryString("TOPIC_ID") 'Response.Write strSql set rsPoll = my_Conn.Execute (strSql) %>
>Poll Preview
<% Dim vAnswers(8) Dim vCount(8) Dim nCount if Request.Querystring("pollresults") <> "1" then %>
Poll Question:
<% =formatStr(rsPoll("T_MESSAGE")) %>

Choices:

<% Dim nDef Dim nTotal Dim nnTotal For nCount=1 To 8 vAnswers(nCount)=rsPoll("answer" & CStr(nCount)) vCount(nCount)=rsPoll("count" & CStr(nCount)) Next For nCount=1 To 8 If trim(vAnswers(nCount)) <> "" Then %> <%=vAnswers(nCount)%>
<% End If Next%>

Voting disabled while in Preview window &FORUM_ID=<%=Request.QueryString("FORUM_ID")%>&CAT_ID=<%=Request.QueryString("CAT_ID")%>&pollresults=1">View Results
<% end if %> <% if Request.Querystring("pollresults") = "1" then %>
Poll Question:
<% =formatStr(rsPoll("T_MESSAGE")) %> <% Dim nMaxValue, nLowValue For nCount=1 To 8 vAnswers(nCount)=rsPoll("answer" & CStr(nCount)) vCount(nCount)=rsPoll("count" & CStr(nCount)) Next 'First of all get max value and nLowValue nMaxValue = 0 For nCount=1 To 8 If trim(vAnswers(nCount)) <> "" and vCount(nCount) > nMaxValue Then nMaxValue = vCount(nCount) End If Next If nMaxValue = 0 Then nMaxValue = 1 End If Dim nMaxWidth Dim vPercent(100) nMaxWidth = 200 'This is number of pixels for maxvalue Dim nThisVal, nPercent nTotal = 0 nnTotal = 0 '1. Go through all and get total For nCount = 1 To 8 If trim(vAnswers(nCount)) <> "" Then nTotal = nTotal + vCount(nCount) nnTotal = nnTotal + vCount(nCount) End If Next If nnTotal = 0 Then nnTotal = 1 End If '2. Go through all and get percent For nCount = 1 To 8 If trim(vAnswers(nCount)) <> "" Then vPercent(nCount) = FormatNumber(vCount(nCount)/nnTotal*100,1) End If Next For nCount=1 To 8 If trim(vAnswers(nCount)) <> "" Then nThisVal = FormatNumber(vCount(nCount)/nMaxValue * nMaxWidth,0) %> <% End If Next %>


Results:

<%=vAnswers(nCount)%>   (<%=vPercent(nCount)%> %) <%=vCount(nCount)%> votes

Total of <%=nTotal%> votes counted so far
<% end if %>