Using ASP to realize online answer game in chat room

Source: Internet
Author: User
Chat Room | Online main function: In the chat room, every 5 minutes, to display the dialogue page, send a question, all users can answer.
The correct person plus the corresponding score.
Concrete implementation: Add an implied frame to the chat room frame,
This frame is refreshed every 5 minutes.
The contents of an ASP page within an implied frame are as follows:
<%@ language=vbscript%>
<%Response.Expires=0%>
<%
Dim Conn,rs
Application.Lock
Application ("Canswername") =application ("Answername") ' Save the name of the user who answered the question correctly
Application ("answername") = ""
Application ("tanswername") = "' Clear the name of the user who answered the wrong question
Set Conn=server.createobject ("ADODB. Connection ")
Accessdb= the connection of "Db1.mdb" ' Item Bank
mydsn= "Driver={microsoft Access DRIVER (*.mdb)};"
MYDSN=MYDSN & "dbq=" &server.mappath (ACCESSDB)
Conn.Open MyDSN
Set Rs = Server.CreateObject ("ADODB.") Recordset ")
Rs.cursorlocation=3
Rs.Open "SELECT * from question", Conn
Randomize ' randomly get the ID of a question
R=rs.recordcount
Id=int ((r-1) *rnd) +1
Rs.close
Set rs=nothing
Set Rs = Server.CreateObject ("ADODB.") Recordset ")
Rs.Open "SELECT * from question where questionid=" &id,conn
Application ("Questionname") =rs ("Questionname") ' Topic
Application ("QuestionID") =rs ("QuestionID") the ID of the question
Application ("Questioncent") =rs ("Questioncent") the score of the question
Description of application ("Questionclass") =rs ("Questionnotes")
Rs.close
Set Rs = Nothing
Set Ra = Server.CreateObject ("ADODB.") Recordset ")
Ra.open "SELECT * from ANSWER where questionid=" &id,conn
Options for application ("Answera") =ra ("Answera")
Application ("Answerb") =ra ("Answerb")
Application ("Answerc") =ra ("Answerc")
Application ("Answerd") =ra ("Answerd")
Application ("Answertrue") =ra ("Answertrue") the correct answer to the question
Ra.close
Set ra=nothing
Conn.close
Set conn=nothing
Application ("Questiontime") =now ()
Application.UnLock
%>
<HTML>
<meta http-equiv= ' content-type ' content= ' text/html; charset=gb2312 ' >
<link rel= ' stylesheet ' href= '. /style.css ' type= ' text/css ' >
<meta http-equiv= "Refresh" content= "300;url=question.asp" >
<title><%=application ("V")%></title>
<script language= "JavaScript" >
Parent. ShowSays.document.write (":******<br> system Message"); Show conversation window to chat room write problem
Parent. ShowSays.document.write ("* * on the title is: <%=application" Canswername ")%><br>");
Parent. ShowSays.document.write ("Question:: <%=application (" Questionname ")%>");
Parent. ShowSays.document.write ("<%=application" ("Questioncent")%> score (within 1 minutes, answer input ' #答案 ') <%=time ()%><br> ") ;
Parent. ShowSays.document.write ("A::<%=application" ("Answera")%><br> ");
Parent. ShowSays.document.write ("B::<%=application" ("Answerb")%><br> ");
Parent. ShowSays.document.write ("C::<%=application" ("Answerc")%><br> ");
Parent. ShowSays.document.write ("D::<%=application" ("Answerd")%><br> ");
</script>
<body bgcolor= ' #FFFFFF ' >
</Body>
Handle the answer part slightly!!!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.