Clan [+35] Forum
Clan [+35] Forum
[+35] Hovedkvarter | Profil | Tilmeld | Aktive emner | Forummedlemmer | Søgning | FAQ
Brugernavn:
Kodeord:
Husk kodeord
Glemt dit kodeord?

 Alle fora
 Computere
 [+35].Net
 Poll system
 Nyt emne  Svar på emnet
 Vis printervenlig version
Forfatter Forrige emne Emne Næste emne  

[+35]Jumpman
[+35] Server Admin, [+35] Member of COW - G5

Denmark
6728 indlæg

Skrevet - 11 Jul 2011 :  14:55:41  Vis profil  Besøg [+35]Jumpman's hjemmeside  Svar med Quote
En der kan ændre koden i denne så den kan kører via mysql istedet for access database database navn kunne være vote_deathcam

<%
'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
%>
<form method="post" action="<%= request.servervariables("script_name") %>">
<p>Skal man kun kunne se sit hold eller skal man se begge hold med deathcam på FFA ?<br>
<input type="radio" value="1" name="u_input" checked >Man skal kun se sit eget hold<br>
<input type="radio" value="2" name="u_input">Man skal se begge hold<br>
<input type="submit" value="Submit" ></p>
</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
' if the directory your .asp page is in does not have user
' write authority the accessdb variable and access db may
' need to be moved to your /cgi-bin/ directory and add that to the code below
accessdb="deathcam"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "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)"
rs.Open sql, cn
end if

'This will summerize and count the records in the db
sql= "select distinctrow "
sql= sql & "sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) as sum_selection2, "
sql= sql & "count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn

total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
count=rs ("total_votes") %>

Skal man kun kunne se sit hold eler skal man se begge hold med deathcam på FFA ?<br>
<img src="red.jpg" height="10" width="<%= formatnumber((total1/count)*100,0) %>">
<%= formatnumber((total1/count)*100,1) %>%<br> Man skal kun se sit eget hold <br>
<img src="blue.jpg" height="10" width="<%= formatnumber((total2/count)*100,0) %>">
<%= formatnumber((total2/count)*100,1) %>%<br> Man skal se begge hold <br>
Total Votes: <%= formatnumber(count,0,0) %><br> <% end if %>
  Forrige emne Emne Næste emne  
 Nyt emne  Svar på emnet
 Vis printervenlig version
Hop til:
Clan [+35] Forum © 2000-2002 Snitz Communications Go To Top Of Page
Tilpasset ældre læsere - vist på [:)] 0.05 sek. Snitz Forums 2000