<%
dim connect, rs, sql, scolor, i
dim arr(4)
set connect = server.createobject("ADODB.Connection")
connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &_
Server.MapPath("\perlphpasp\db\quiz.mdb"))
sql = "select * from math01"
set rs = connect.execute(sql)
response.write("<body><table bgcolor=#000000>")
i = 1
do while not rs.eof
if scolor = "silver" Then scolor = "white" else scolor = "silver" end if
arr(1) = rs("choice1")
arr(2) = rs("choice2")
arr(3) = rs("choice3")
arr(4) = rs("choice4")
response.write("<tr bgcolor='" & scolor & "'>")
response.write("<td>" & i & "</td>")
response.write("<td>" & rs("question") & "</td>")
response.write("<td>" & arr(rs("ans")) & "</td>")
' ok : response.write("<td>" & rs("choice"&rs("ans")) & "</td>")
response.write("</tr>")
rs.movenext
i = i + 1
loop
response.write("</table></body>")
connect.close
set rs = nothing
set connect = nothing
%>
จำนวน : 30 บรรทัด