asp调用指定分类的文章,怎么修改代码 5
<%Setrs=server.CreateObject("adodb.recordset")sql="selecttop5*frompf_newsorderbypf_ne...
<%
Set rs = server.CreateObject("adodb.recordset")
sql = "select top 5 * from pf_news order by pf_news_order desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
Set rsc = server.CreateObject("adodb.recordset")
sql = "select * from pf_news_category where id=4"
rsc.Open sql, conn, 1, 1
%>
<li>[<a href="news_category.asp?id=<%=rsc("ID")%>"><%=rsc("pf_news_category_name")%></a>] <a href="news_view.asp?id=<%=rs("ID")%>" title="<%=rs("pf_news_name")%>"><%=left(rs("pf_news_name"),25)%></a></li>
<%
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>我写的这样的,分类调出来了,但是文章没有调出来 调出来还是全部的文章,我想把指定分类的文章调出来 展开
Set rs = server.CreateObject("adodb.recordset")
sql = "select top 5 * from pf_news order by pf_news_order desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
Set rsc = server.CreateObject("adodb.recordset")
sql = "select * from pf_news_category where id=4"
rsc.Open sql, conn, 1, 1
%>
<li>[<a href="news_category.asp?id=<%=rsc("ID")%>"><%=rsc("pf_news_category_name")%></a>] <a href="news_view.asp?id=<%=rs("ID")%>" title="<%=rs("pf_news_name")%>"><%=left(rs("pf_news_name"),25)%></a></li>
<%
rsc.Close
Set rsc = Nothing
rs.movenext
Loop
rs.Close
Set rs = Nothing
%>我写的这样的,分类调出来了,但是文章没有调出来 调出来还是全部的文章,我想把指定分类的文章调出来 展开
2个回答
展开全部
既然是指定分类的文章,那么怎么也得先获取分类,然后在获取文章吧,你的那个逻辑好像反了!
追问
那代码要怎么写吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
pf_news是文章表,pf_news_category 是栏目表吧
如果是那下面这些就不用要了
Set rsc = server.CreateObject("adodb.recordset")
sql = "select * from pf_news_category where id=4"
rsc.Open sql, conn, 1, 1
直接用这个就行了,加个栏目条件
Set rs = server.CreateObject("adodb.recordset")
sql = "select top 5 * from pf_news where 栏目id=4 order by pf_news_order desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
....
如果是那下面这些就不用要了
Set rsc = server.CreateObject("adodb.recordset")
sql = "select * from pf_news_category where id=4"
rsc.Open sql, conn, 1, 1
直接用这个就行了,加个栏目条件
Set rs = server.CreateObject("adodb.recordset")
sql = "select top 5 * from pf_news where 栏目id=4 order by pf_news_order desc"
rs.Open sql, conn, 1, 1
Do While Not rs.EOF
....
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询