我试图为菜单创建一个嵌套循环,但它返回错误。请有人可以帮我解决这个问题。甚至确定循环出错的地方。
Error Type:
Microsoft VBScript compilation (0x800A040E)
'loop' without 'do'
/asp/default.asp, line 64
loop until RS.EOF
编码
msql = "SELECT * FROM tblMenu ORDER BY [link_position] ASC"
Set RS = Server.CreateObject("ADODB.Recordset")
Set RSsub = Server.CreateObject("ADODB.Recordset")
RS.Open msql, Conn, 1,3
RSsub.Open msql
If Not RS.EOF Then
Do
Response.Write "<li><a href="""& RS("link")&""" title ="""& RS("link_title")&""">"& RS("link_name") &"</a>"
If NOT RSsub.EOF Then
Response.Write("<ul>" & vbcrlf)
Do While NOT RSsub.EOF
Response.Write(RSsub("sub_menu") & vbcrlf)
RSsub.MoveNext
Loop
Response.Write("</ul>" & vbcrlf)
RSsub.Close
Response.Write("</li>" & vbcrlf)
RS.MoveNext
loop until RS.EOF
End if
预期产出
<li><a href="some-link" title="">Record from DB</a>
<ul>
<li><a href="some-link">Records from DB</a></li>
</ul>
</li>