|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Update database/count statement
i am trying to create a question page, i am useing a select/ case statement to to query my ansmap. but i know i need to have a count statement but i am unsure on how to do that. can any one assist.
here is my code <% dim ansMap1, ansMap2, ansMap3, ansMap4, ansMap5, ansMap6, ansMap7, ansMap8, ansMap9, ansMap10, Count, Total, Form1, strUserName, StrScore, StrCorrectAnswer set rs = Server.CreateObject("ADODB.Connection") conn.open "Driver={Microsoft Access Driver (*.mdb)};DBQ=e:\home\shughes\db\final.mdb" rs.open"quiz", conn, 1,3 rs.addnew rs("score") = strScore ' annswer key ' ansMap1="d" ansMap2="b" ansMap3="a" ansMap4="a" ansMap5="b" ansMap6="c" ansMap7="b" ansMap8="c" ansMap9="b" ansMap10="a" 'count function' Do while Count > 0 count = count + CorrectAnswer form1 = Request.Form("Form1") ' select from form1 statement ' for loop select case form1 case "select1" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select2" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select3" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select4" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select5" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select6" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select7" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select8" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select9" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if case "select10" if "select1" = "ansMap1" then CorrectAnswer = count+1 end if end select loop ' insert update statement' strQuery = "update Final set Score = '" & strCorrectAnswer & "' where Username = '" & strUserName & "'" Conn.execute(strQuery) %> <div align="center"> <h1>The Dreaded Quiz</h1> <p>Please answer as many as you can!</p> <p>Good Luck, you will need it.</p> <p> </p> <form name="form1" method="post" action="quizscore.html"> <p align="left"> <select name="select1"> <option>A</option> <option>B</option> <option>C</option> <option>D</option> </select> Question 1. What is the first thing that happens when you power on a cell phone, what does it look for? </p> <p align="center"> A. Operations System B. Electronic Serial Number C. Mobile Identification number D. System Identification code </p> <p align="left"> |
|
#2
|
|||
|
|||
|
- Create a table with all the answers.
- Read the tabel into recordset. - Use a Loop to check if the answer provided match the recordset. - Add up all the CorrectAnswer count. |
|
#3
|
|||
|
|||
|
not sure what you mean i am still new at this, kinda flying by the seat of my paints.
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Update database/count statement |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|