It looks like you don't quite understand how recordsets work, so let's go through your code and explain what's happening.
After this first bit of code is run:
Code:
sqltext1 = "SELECT * FROM StudentTable WHERE StudentID='" & Session("username") & "'"
oRS.Open sqltext1, oConn
you have a recordset (oRS) which contains all 4 records, and its automatically positioned at the first record, so when you do the test:
Code:
IF oRS("quiz_id") = "1" Then
the result is TRUE and so the score is written to the browser by your next line of code.
So, when you repeat the code:
Code:
sqltext2 = "SELECT * FROM StudentTable WHERE StudentID='" & Session("username") & "'"
oRS.Open sqltext1, oConn
you again get a recordset containing all 4 records which is positioned at the first record, so this time your test:
Code:
IF oRS("quiz_id") = "2" Then
fails.
So, can you see that instead of repeating the SQL, all you need to do is oRS.MoveNext? That will position the recordset to the second record (the one with quizid=2). Personally I would add an ORDER BY clause to the SQL to ensure you always get the records back in the sequence you expect:
SELECT * FROM StudentTable WHERE StudentID='" & Session("username") & "' ORDER BY StudentID, quiz_id"
hth
Phil