我需要有关循环的帮助,这是我的表结构和记录。我想要的是循环记录每个U_ID
有多个相同的记录U_ID
。
SQL 查询
Set Rs2 = con.execute("Select U_ID, stdName, Class_Code, subject, total_marks, act_marks, obt_marks, Format(submit_date,'dd-MMM-yyyy') as submit_date From res_correct ORDER BY submit_date, subject, Class_Code")
我的 ASP 代码:
If Not RS2.EOF Then
Response.write "<table width=""80%"">"& vbcrlf
Response.write "<tr>"& vbcrlf
Response.write "<td><strong>Name:</strong><span class=""underline"">"& Rs2("stdName")&" </span></td>" & vbcrlf
Response.write "<td><strong>Class:</strong> <span class=""underline"">" & Rs2("Class_Code")&" </span></td>" & vbcrlf
Response.write "<td><strong>UID:</strong> <span class=""underline"">"& Rs2("U_ID") &"</span></td>"& vbcrlf
Response.write "<td><strong>Date:</strong> <span class=""underline"">"& Rs2("submit_date") &"</span></td>"& vbcrlf
Response.write "</tr>" &vbcrlf
Response.write "<tr class=""trhead2"">" &vbcrlf
Response.write "<td>Subject</td>" &vbcrlf
Response.write "<td>Total Marks</td>" &vbcrlf
Response.write "<td>Obtained Marks</td>" &vbcrlf
Response.write "<td>Actual Marks</td>" &vbcrlf
Response.write "</tr>" &vbcrlf
Rs2.MoveFirst
Do
Response.Write "<tr class=""trhighlight"">" &vbcrlf
Response.Write "<td>"& Rs2("Subject") &" </td>" &vbcrlf
Response.Write "<td>"& Rs2("total_marks")&" </td>" &vbcrlf
Response.Write "<td>"& Rs2("obt_marks")&" </td>" &vbcrlf
Response.Write "<td>"& Rs2("act_marks")&" </td>" &vbcrlf
Response.Write "</tr>" &vbcrlf
RS2.MoveNext()
Loop Until RS2.EOF
Response.write "</table>" &vbcrlf
End If
我需要的输出结果如下:
相反,我得到了这个
谢谢!!!