显示多个ASP项目



我需要显示多个ASP项。我们有一个后端工具,可以在其中添加多个条目,但只显示前两个条目。我希望有一个小的代码调整,将允许显示更多的页面。显示代码的2个页面的代码如下:

<%
dim sql
sql = "select * from announcement_table where ann_status=1"
set rs = con.execute(sql)
%>
<%if not(rs.eof and rs.bof) then%>
<p><strong><%=rs("ann_title")%></strong> </p>
<p><%=rs("ann_text")%>
    <%else%>
  Currently there are no announcements.
  <%
end if
rs.close
set rs = nothing
%>
 </p>   
<hr size="1" noshade>
<%
dim sql_, sqlcount
sqlcount = "select count(*) from announcement_table"
set rscount = con.execute(sqlcount) 
sql_ = "select * from announcement_table where ann_status <> 1"
set rs_ = con.execute(sql_)
%>
<%if rscount(0)>1 then%>
<%if not(rs_.eof and rs_.bof) then%>
<a href="announcements_more.asp?ann_id=<%=rs_("ann_id")%>"><%=rs_("ann_title")%></a>         <br>
  <%else%>
  Currently there are no announcements.
    <%
end if
rs_.close
set rs_ = nothing
%>
<%end if
rscount.close
set rscount = nothing
%>

这是第2页:

<%
dim sql_
sql_ = "select * from announcement_table where ann_id=" & intann_id
set rs_ = con.execute(sql_)
%>
<p><strong><%=rs_("ann_title")%></strong> </p>
<p><%=rs_("ann_text")%></p>
<%rs_.close
set rs_ = nothing
%>

在第二个页面中,您需要循环遍历记录集以显示多个值。

<%
    dim sql_
    sql_ = "select * from announcement_table where ann_id=" & intann_id
    set rs_ = con.execute(sql_)
    While Not rs_.EOF
    %>
    <p><strong><%=rs_("ann_title")%></strong> </p>
    <p><%=rs_("ann_text")%></p>
    <%
    rs_.Movenext
    Wend
    rs_.close
    set rs_ = nothing
    %>

并检查此链接。SQL注入

最新更新