统计了局 survey_vote.asp
<!--#include file="inc.asp" -->
<html>
<head>
<title>查询拜访统计了局</title>
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<%
'上一句先到场包括文件,援用函数。
id=request.querystring("id") '获得querystring参数id
opendb my '毗连数据库
if id="" then '假如没有,则不是直接看了局
id=request.form("id") '获得form参数id
if id<>"" then '假如有值,则是要先统计
surveycount() '挪用统计子法式
end if
end if
if id<>"" then
disp_survey() '不论是哪一种,最初都显示了局
end if
closedb my '封闭数据库
'-----统计子法式-----
sub surveycount()
if session("survey_ok")="" then '假如还没投票
no=request.form("res") '失掉谜底的编号
if no<>"" then
'界说SQL语句,让提交的谜底数目+1
sql="update survey_vote set vote_count=vote_count+1 where vote_no in (" & no &")"
my.execute sql
end if
session("survey_ok")="ok"
end if
end sub
'------------------
'---显示了局子法式---
sub disp_survey()
'界说SQL语句,失掉查询拜访的成绩
sql="select survey_question from survey where survey_id=" & id
searchtable my,sql,rs '履行查询
question=rs("survey_question") '把成绩存到question中
closetable rs '封闭表
'界说SQL语句,失掉谜底的数目总和
sql="select sum(vote_count) as total from survey_vote where vote_id="& id
searchtable my,sql,rs
total=rs("total")
closetable rs '封闭表