0

我需要显示多个 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
%>
4

1 回答 1

1

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

<%
    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 注入

于 2013-08-01T05:54:39.493 回答