F
foxmail
Unregistered / Unconfirmed
GUEST, unregistred user!
[]我做了一个关于女足表现的调查表,是和sql连的,比较简单,由3个asp组成,但总是调不出,好象
还是vote.asp和resutl.asp有问题,请指教!
wanyong表的结构如下:
ip 文本
selection1 数字
selection2 数字
selection3 数字
selection4 数字
entered 日期
default.asp:
<form method="post" action="vote.asp">
<p>中国女足最近表现怎样??<br>
<input type="radio" value="1" name="u_input" checked>很好<br>
<input type="radio" value="2" name="u_input" >较好<br>
<input type="radio" value="3" name="u_input" >一般<br>
<input type="radio" value="4" name="u_input" >较差<br>
<input type="submit" value="投票" >
<input type="button" value="看结果" onclick="window.showModalDialog('result.asp?u_input='+document.all.u_input.value, '', 'dialogHeight = 25;dialogWidth = 22;help = off;');
">
<H2><b></h2>
</form>
vote.asp:
<%
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")
set conn=server.createobject("adodb.connect")
conn.open"dsn=poll;mid=sa;pwd=sa"
set rs = server.createobject("ADODB.Recordset")
sql = "insert into wanyong (ip, selection" &
u_input &") "
sql = sql &
"values ('" &
u_ip &
"',1)"
rs.activeconnection=conn
rs.Open sql
set rs=nothing
response.redirect "default.asp"
%>
result.asp:
<%
u_input=request("u_input")
u_ip=request.servervariables("remote_addr")
set conn=server.createobject("adodb.connect")
conn.open"dsn=poll;mid=sa;pwd=sa"
set rs = server.createobject("ADODB.Recordset")
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql &
"sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, sum(selection4) AS sum_selection4,"
sql= sql &
" count(*) AS total_votes "
sql= sql &
"FROM wanyong;"
rs.activeconnection=conn
rs.Open sql
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
count=rs ("total_votes")
if count=0 then
count=1
%>
<br>
<center>
<h2>结果:</h2>
</center>
<p align="center">很好:有<%=total1%>人,占
<%= formatnumber((total1/count)*100,1) %>%<img src="red.jpg" height="10" width="<%= (total1/count)*100 %>">
<p align="center">较好:有<%=total2%>人,占
<%= formatnumber((total2/count)*100,1) %>%<img src="yellow.jpg" height="10" width="<%= (total2/count)*100 %>"><br>
一般:有<%=total3%>人,占
<%= formatnumber((total3/count)*100,1) %>%<img src="green.jpg" height="10" width="<%= (total3/count)*100 %>"><br>
较差:有<%=total4%>人,占
<%= formatnumber((total4/count)*100,1) %>%<img src="blue.jpg" height="10" width="<%= (total4/count)*100 %>"><br>
<BR>
<BR>
共有投票人: <%= formatnumber(count,0,0) %><br>
你来自: <%= u_ip %>
<% set rs=nothing%>
<br>
<input type=button value="关闭" onclick="window.close();"></p>
还是vote.asp和resutl.asp有问题,请指教!
wanyong表的结构如下:
ip 文本
selection1 数字
selection2 数字
selection3 数字
selection4 数字
entered 日期
default.asp:
<form method="post" action="vote.asp">
<p>中国女足最近表现怎样??<br>
<input type="radio" value="1" name="u_input" checked>很好<br>
<input type="radio" value="2" name="u_input" >较好<br>
<input type="radio" value="3" name="u_input" >一般<br>
<input type="radio" value="4" name="u_input" >较差<br>
<input type="submit" value="投票" >
<input type="button" value="看结果" onclick="window.showModalDialog('result.asp?u_input='+document.all.u_input.value, '', 'dialogHeight = 25;dialogWidth = 22;help = off;');
">
<H2><b></h2>
</form>
vote.asp:
<%
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")
set conn=server.createobject("adodb.connect")
conn.open"dsn=poll;mid=sa;pwd=sa"
set rs = server.createobject("ADODB.Recordset")
sql = "insert into wanyong (ip, selection" &
u_input &") "
sql = sql &
"values ('" &
u_ip &
"',1)"
rs.activeconnection=conn
rs.Open sql
set rs=nothing
response.redirect "default.asp"
%>
result.asp:
<%
u_input=request("u_input")
u_ip=request.servervariables("remote_addr")
set conn=server.createobject("adodb.connect")
conn.open"dsn=poll;mid=sa;pwd=sa"
set rs = server.createobject("ADODB.Recordset")
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql &
"sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, sum(selection4) AS sum_selection4,"
sql= sql &
" count(*) AS total_votes "
sql= sql &
"FROM wanyong;"
rs.activeconnection=conn
rs.Open sql
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
count=rs ("total_votes")
if count=0 then
count=1
%>
<br>
<center>
<h2>结果:</h2>
</center>
<p align="center">很好:有<%=total1%>人,占
<%= formatnumber((total1/count)*100,1) %>%<img src="red.jpg" height="10" width="<%= (total1/count)*100 %>">
<p align="center">较好:有<%=total2%>人,占
<%= formatnumber((total2/count)*100,1) %>%<img src="yellow.jpg" height="10" width="<%= (total2/count)*100 %>"><br>
一般:有<%=total3%>人,占
<%= formatnumber((total3/count)*100,1) %>%<img src="green.jpg" height="10" width="<%= (total3/count)*100 %>"><br>
较差:有<%=total4%>人,占
<%= formatnumber((total4/count)*100,1) %>%<img src="blue.jpg" height="10" width="<%= (total4/count)*100 %>"><br>
<BR>
<BR>
共有投票人: <%= formatnumber(count,0,0) %><br>
你来自: <%= u_ip %>
<% set rs=nothing%>
<br>
<input type=button value="关闭" onclick="window.close();"></p>