%
t = 1
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open dsn
SQL = "SELECT * from que order by id desc"
rs.open sql,conn
do while not rs.eof
if t = 4 then
t = 1
end if
queID = rs("ID")
sql1 = "select * from ans where queID="&queID
sql2 = "SELECT SUM(total) FROM ans where queID="&queID
response.write "" & rs("que") & "
"
set rs1 = conn.execute(sql1)
set us = conn.execute(sql2 )
'You will get directly the final total
final_total=us(0).value
set us=nothing
do while not rs1.eof
ansTotal = rs1("total")
if ansTotal=0 then
ansPercent="0%"
else
ansPercent=formatpercent(ansTotal/final_total)
end if
ansImage = replace(ansPercent,"%","")
ansImage = ansImage*2
response.write rs1("ansdesc") & " - " & "
" & ansPercent & "
"
rs1.movenext
t = t + 1
loop
rs.movenext
loop
%>