asp执行两个循环时出错,要读取一个新闻分类,然后是这个分类下的新闻条数
实现一个页面显示多个新闻分类和这个分类下的新闻条目<ulclass="news"><%Setrs=server.CreateObject("adodb.recordset...
实现一个页面显示多个新闻分类和这个分类下的新闻条目
<ul class="news">
<%
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from news_category where show=false order by id desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
%>
<li>[<a href="news_category.asp?id=<%=rs("ID")%>"><%=rs("news_category_name")%></a>]</li>
<%
Set rsc = server.CreateObject("adodb.recordset")
sql = "select top 4 * from news where pf_news_category = "&rs("ID")&" order by pf_news_order desc"
rsc.Open sql, conn, 1, 1
If rsc.eof and rsc.bof then
else
%>
<li><span class="float_right red"><%=formatdatetime(rsc("news_date"),2)%></span><a href="news_view.asp?id=<%=rsc("ID")%>" title="<%=rsc("news_name")%>"><%=left(rsc("news_name"),30)%></a></li>
<%
rsc.movenext
Loop
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>
</ul> 展开
<ul class="news">
<%
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from news_category where show=false order by id desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
%>
<li>[<a href="news_category.asp?id=<%=rs("ID")%>"><%=rs("news_category_name")%></a>]</li>
<%
Set rsc = server.CreateObject("adodb.recordset")
sql = "select top 4 * from news where pf_news_category = "&rs("ID")&" order by pf_news_order desc"
rsc.Open sql, conn, 1, 1
If rsc.eof and rsc.bof then
else
%>
<li><span class="float_right red"><%=formatdatetime(rsc("news_date"),2)%></span><a href="news_view.asp?id=<%=rsc("ID")%>" title="<%=rsc("news_name")%>"><%=left(rsc("news_name"),30)%></a></li>
<%
rsc.movenext
Loop
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>
</ul> 展开
展开全部
<ul class="news">
<%
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from news_category where show=false order by id desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
%>
<li>[<a href="news_category.asp?id=<%=rs("ID")%>"><%=rs("news_category_name")%></a>]</li>
<%
Set rsc = server.CreateObject("adodb.recordset")
sql c= "select top 4 * from news where pf_news_category = "&rs("ID")&" order by pf_news_order desc"
rsc.Open sqlc, conn, 1, 1
If not rsc.eof then
%>
<li><span class="float_right red"><%=formatdatetime(rsc("news_date"),2)%></span><a href="news_view.asp?id=<%=rsc("ID")%>" title="<%=rsc("news_name")%>"><%=left(rsc("news_name"),30)%></a></li>
<%
rsc.movenext
Loop
end if
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>
</ul>
<%
Set rs = server.CreateObject("adodb.recordset")
sql = "select * from news_category where show=false order by id desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
%>
<li>[<a href="news_category.asp?id=<%=rs("ID")%>"><%=rs("news_category_name")%></a>]</li>
<%
Set rsc = server.CreateObject("adodb.recordset")
sql c= "select top 4 * from news where pf_news_category = "&rs("ID")&" order by pf_news_order desc"
rsc.Open sqlc, conn, 1, 1
If not rsc.eof then
%>
<li><span class="float_right red"><%=formatdatetime(rsc("news_date"),2)%></span><a href="news_view.asp?id=<%=rsc("ID")%>" title="<%=rsc("news_name")%>"><%=left(rsc("news_name"),30)%></a></li>
<%
rsc.movenext
Loop
end if
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>
</ul>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询