14. august 2005 - 22:26
#1
<%
'Two varibles are passed into the db
'u_input is the value if the user entered a response to
'the vote/poll question....IP is the address of the user
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")
' if the user did not enter anything in the poll on this visit
' then display the poll question and possible choices
if u_input = "" then
%>
<html><head>
<title>Stemmeboks</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type=text/css>
A:link {COLOR: #CC6600; TEXT-DECORATION: none}
A:visited {COLOR: #CC6600; TEXT-DECORATION: none}
A:hover {COLOR: #CC3300; TEXT-DECORATION: none}
A:active {COLOR: #CC6600; TEXT-DECORATION: none}
.style1 {
color: #CC6600;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style2 {
color: #000000;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style3 {
color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
a {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style5 {color: #000000; font-weight: bold;}
</STYLE>
</head>
<body bgcolor="#999999">
<div align="center">
<table width="400" height="529" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" background="Scroll.jpg">
<tr>
<td width="395" height="525">
<table width="209" border="0" align="center" cellpadding="4" cellspacing="2">
<tr>
<td width="197" height="494">
<form method="post" action="<%= request.servervariables("script_name") %>">
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<strong class="style2">Hvis du har prøvet noget her på siden,
hvor brugbart var det for dig?</strong> <br>
<br>
</font> <span class="style1"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<input type="radio" name="u_input" value="1">
Brugbart<br>
<input type="radio" name="u_input" value="2">
tildels brugbart <br>
<input type="radio" name="u_input" value="3">
Kunne ikke bruges <br>
<input type="radio" name="u_input" value="4">
For svær <br>
<input type="radio" name="u_input" value="5">
For let </font></span></div>
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<input type="submit" name="Stem" value="Stem" maxlength="50" style="font-family: verdana; font-size: 10px; HEIGHT: 17px; border-style: double; border-color:#006600; border-width: 1px; WIDTH: 50px; background-color: #FFFFFF; border-style: double; border-width: 1px" size="31">
</font></div>
</form>
<%
else
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
Set objConn = Server.CreateObject("ADODB.Connection")
set rs = server.createobject("ADODB.Recordset")
objConn.ConnectionString="DRIVER={MySQL};SERVER=localhost;DATABASE=sights_dk;UID=sights_dk;PWD=mozart;"
objConn.Open
set rs = objConn.execute("select ip from ballot where ip ='" & u_ip & "'")
'rs.Open sql, cn
if rs.eof then
' if the user has not voted previously indicate it
been_here_before="No"
end if
rs.close
if been_here_before = "No" then
' Since the user has not voted previously their input
' their vote will be added to the db
sql = "insert into ballot (ip, selection" & u_input &") "
sql = sql & "values ('" & u_ip & "',1)"
end if
'This will summerize and count the records in the db
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, "
sql= sql & "sum(selection4) AS sum_selection4, count(*) AS total_votes "
sql= sql & "FROM ballot;"
set rs = objConn.execute(sql)
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
count=rs ("total_votes")
%>
<div align="center">
<style type=text/css>
A:link {COLOR: #CC6600; TEXT-DECORATION: none}
A:visited {COLOR: #CC6600; TEXT-DECORATION: none}
A:hover {COLOR: #CC6600; TEXT-DECORATION: none}
A:active {COLOR: #CC6600; TEXT-DECORATION: none}
</style>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</div>
<div align="center" class="style1">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Stemmeresultater</font></font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<%
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={MySQL};SERVER=localhost;DATABASE=sights_dk;UID=sights_dk;PWD=mozart;"
objConn.Open
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, "
sql= sql & "sum(selection4) AS sum_selection4, sum(selection5) AS sum_selection5, count(*) AS total_votes "
sql= sql & "FROM ballot;"
set rs = objConn.execute(sql)
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
total5=rs ("sum_selection5")
count=rs ("total_votes")
%>
</font>
<table width="400" height="529" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" background="Scroll.jpg">
<tr>
<td width="100%" valign="middle"> <table width="34%" border="0" align="center">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Brugbart</font><br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><img src="red.jpg" height="10" width="38">
<%= ((total1/count)*100) %>%<br>
<br>
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Tildels
brugbart</font><br> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><img src="red.jpg" height="10" width="38">
<%= ((total2/count)*100) %>%<br>
<br>
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Kunne
ikke bruges</font><br> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><img src="red.jpg" height="10" width="38">
<%= ((total3/count)*100) %>%</font>
<br> <br> <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Kunne
ikke bruges</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<img src="red.jpg" height="10" width="38"> <%= ((total4/count)*100) %>%</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">Kunne
ikke bruges</font> <br>
<img src="red.jpg" height="10" width="38"> <%= ((total5/count)*100) %>%</font></td>
</tr>
</table>
<p align="center" class="style3"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><span class="style2">Antal
stemmer:</span></font><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<%= (count) %><br>
</font></p></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table>
</div>
</body>
<% end if %>
</html>