我需要显示多个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
%>
答案 0 :(得分: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 Injection