<head>
<link rel="stylesheet" type="text/css" href="../css/xmwuye.css">
</head>
<!--#include file="../inc/conn.asp"-->
<%
lookpollid=Request.QueryString("lookpollid")
if lookpollid<>"" then
   str="select sum(票数) as total from BBS_Poll where pid="&lookpollid
   set rstp=conn.execute(str)
   Vote_Count_Total=rstp("total")
   Set rs = Server.CreateObject("ADODB.Recordset")
   sql="SELECT top 11 * FROM BBS_Poll where id="&lookpollid&" or pid="&lookpollid&" "
   rs.open sql,conn,1,1
   'rs.movenext
   Response.Write "<table width=""99%"" border=0 align=""center"" cellpadding=2 cellspacing=1 bgcolor=""#A4B6D7"">"
   Response.Write "<tbody>"
   Response.Write "<tr background=""../bbs/images/bbs_bg1.gif"">" 
   Response.Write "<td height=""25"" background=""../bbs/images/bbs_bg1.gif"">" 
   Response.Write "<div align=""center""></div>"
   Response.Write "<div align=""center"">查看投票</div></td>"
   Response.Write "</tr>"
   Response.Write "</tbody>"   
   Response.Write "</table>"   
   Response.Write "<table width=""99%"" align=center border=0 cellpadding=2 cellspacing=1 bgcolor=""#A4B6D7"">"
   Response.Write "<tr bgcolor=""#F2F8FF""><td width=""65%"" height=25>&nbsp;投票主题:"+rs("选项内容")+"</td><td align=left class=light width=""35%"">&nbsp;总共有"&Vote_Count_Total&"票</font></td></tr>"
   rs.movenext
   while not rs.eof
		Vote_count=rs("票数")'投票数
		if vote_count=0 then
			per=0
		else
			per=formatnumber(Vote_count/Vote_Count_Total*100,2)&"%"
		end if
		tpnum=cstr(rs("票数"))
   'if rs("pid")=0 then
      'Response.Write "<tr bgcolor=""#F2F8FF""><td colspan=2 width=""65%"" height=25>&nbsp;主题:"+rs("选项内容")+"</td><td align=left class=light width=""35%"">&nbsp;总共有"&Vote_Count_Total&"票</font></td></tr>" 
   'else
      Response.Write "<tr bgcolor=""#F2F8FF""><td height=27 class=light>&nbsp;"&rs("选项内容")&"</td><td align=left class=light width=""35%""><img height=10 src=images/1.gif width="&per&" align=""middle"">&nbsp;共"&tpnum&"票&nbsp;占<font color=red>"&per&"</font></td></tr>"
   'end if
   rs.movenext
   wend
   response.write "</table>"
else
'speak="<center>投票内容不能为空</center>"
tptype=Request.QueryString("tptype")
pollid=Request.QueryString("pollid")
tpnl=Request.Form("tp")
if tptype<>"" and tpnl<>"" then
 if tptype=1 then
   if session("ip")<>"" then
    response.write "<script language='javascript'>"
    response.write "alert('你已经投过票了！');"
    response.write "history.go(-1);"
    response.write "</script>"
    response.end   
   end if
   Set rs = Server.CreateObject("ADODB.Recordset")
   sql="SELECT top 1 * FROM BBS_Poll where id="&tpnl&" "
   rs.open sql,conn,1,3
   if not (rs.BOF and rs.EOF) then
    rs("票数")=rs("票数")+1
    rs.Update
	session("IP")=Request.ServerVariables("remote_addr")
	session("lookpollid")=lookpollid
    response.write "<script language='javascript'>"
    response.write "alert('投票成功！');"
    response.write "history.go(-1);"
    response.write "</script>"
    response.end
   else
    Response.Write "没有找到这个选项"
   end if
   rs.Close
   set rs=nothing
 else
   if session("ip")<>"" then
    response.write "<script language='javascript'>"
    response.write "alert('你已经投过票了！');"
    response.write "history.go(-1);"
    response.write "</script>"
    response.end   
   end if
   Set rs = Server.CreateObject("ADODB.Recordset")
   sql="SELECT top 11 * FROM BBS_Poll where pid="&pollid&" "
   rs.open sql,conn,1,3
   rs.movenext
   while not rs.eof
   if instr(1,tpnl,cstr(rs("id")))<>0 then
   rs("票数")=rs("票数")+1
   rs.Update
   end if   
   rs.movenext
   wend
   rs.close
   set rs=nothing
   session("IP")=Request.ServerVariables("remote_addr")
   session("lookpollid")=lookpollid
   response.write "<script language='javascript'>"
   response.write "alert('投票成功！');"
   response.write "history.go(-1);"
   response.write "</script>"
   response.end
 end if
else
   response.write "<script language='javascript'>"
   response.write "alert('投票内容不能为空！');"
   response.write "history.go(-1);"
   response.write "</script>"
   response.end
end if
end if
set conn=nothing
%>