DEMO :

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

Displaying survey

<%if Session("useron") = "granted" then%> >> Back to Admin <%end if%> <% Dim sConnection, objConn , objRS sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=sql3a.your-server.co.za; DATABASE=cmwebd_db1; UID=cmwebd_1;PASSWORD=TjhHgmLR; OPTION=3" Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open(sConnection) Set objRS = objConn.Execute("SELECT * FROM SURVEYTABLE") %> <%DO WHILE NOT objRS.EOF Dim sConnection2, objConn2 , objRS2 sConnection2 = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=sql3a.your-server.co.za; DATABASE=cmwebd_db1; UID=cmwebd_1;PASSWORD=TjhHgmLR; OPTION=3" Set objConn2 = Server.CreateObject("ADODB.Connection") objConn2.Open(sConnection2) Set objRS2 = objConn2.Execute("SELECT answer FROM ANSWERTABLE WHERE ANSWER = 'yes' AND surveyindex = '" & objRS("thisindex") & "'") Dim numberyes numberyes = 0 do while not objRS2.EOF numberyes = numberyes + 1 objRS2.movenext loop Set objRS2 = objConn2.Execute("SELECT answer FROM ANSWERTABLE WHERE ANSWER = 'no' AND surveyindex = '" & objRS("thisindex") & "'") Dim numberno numberno = 0 do while not objRS2.EOF numberno = numberno + 1 objRS2.movenext loop objRS2.Close Set objRS2 = Nothing objConn2.Close Set objConn2 = Nothing 'percentage calculation dim total total = numberyes + numberno dim percentyes if total <> 0 then percentyes = 100 / total * numberyes dim percentno percentno = 100 / total * numberno end if %>
<%if Not IsNull(objRS("survey")) then Response.write(objRS("survey")) end if %> Yes <%=FormatNumber(percentyes,0)%>% No <%=FormatNumber(percentno,0)%>%
Yes No "/> Total answered: <%=total%>

<%if Session("useron") = "granted" then%> >>" style="text-decoration: none">edit the above survey              >>" style="text-decoration: none"> delete the above survey <%end if %>
<% objRS.MoveNext Response.Flush() LOOP objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing %>