asp 网页设计中分页显示代码
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!--#includefile="../include/conn.asp"--><%Dims...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../include/conn.asp" -->
<%
Dim strSql,rs
strSql ="Select * From rbook Order By rbook_register_date Desc"
Set rs=conn.execute(strSql)
Do While Not rs.Eof
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CAD9EA">
<tr>
<td height="62" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="238" colspan="2" rowspan="12"><img src="<%=rs("rbook_image")%>" border="1" align="absmiddle" /></td>
</tr>
<tr>
<td width="116" height="40"><strong>书名 </strong></td>
<td width="189" height="40"><%=rs("rbook_name")%></td>
</tr>
<tr>
<td height="40"><strong>作者 </strong></td>
<td height="40"><%=rs("rbook_author")%></td>
</tr>
<tr>
<td height="40"><strong>出版社</strong></td>
<td height="40"><%=rs("rbook_publisher")%></td>
</tr>
<tr>
<td height="40"><strong>类型</strong></td>
<td height="40"><%=rs("rbook_type")%></td>
</tr>
<tr>
<td height="40"><strong>上传用户</strong></td>
<td height="40"><%=rs("rbook_user")%></td>
</tr>
<
</table>
<%
rs.MoveNext
Loop
%>
从数据库中提取信息,并想实现每页只显示两组返回的结果,请问怎样修改代码?
详细代码 展开
<!--#include file="../include/conn.asp" -->
<%
Dim strSql,rs
strSql ="Select * From rbook Order By rbook_register_date Desc"
Set rs=conn.execute(strSql)
Do While Not rs.Eof
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CAD9EA">
<tr>
<td height="62" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="238" colspan="2" rowspan="12"><img src="<%=rs("rbook_image")%>" border="1" align="absmiddle" /></td>
</tr>
<tr>
<td width="116" height="40"><strong>书名 </strong></td>
<td width="189" height="40"><%=rs("rbook_name")%></td>
</tr>
<tr>
<td height="40"><strong>作者 </strong></td>
<td height="40"><%=rs("rbook_author")%></td>
</tr>
<tr>
<td height="40"><strong>出版社</strong></td>
<td height="40"><%=rs("rbook_publisher")%></td>
</tr>
<tr>
<td height="40"><strong>类型</strong></td>
<td height="40"><%=rs("rbook_type")%></td>
</tr>
<tr>
<td height="40"><strong>上传用户</strong></td>
<td height="40"><%=rs("rbook_user")%></td>
</tr>
<
</table>
<%
rs.MoveNext
Loop
%>
从数据库中提取信息,并想实现每页只显示两组返回的结果,请问怎样修改代码?
详细代码 展开
2个回答
展开全部
设置页大小为2
=================================================================
我帮你改一下
加入了翻页 等!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../include/conn.asp" -->
<%
Dim strSql,rs
strSql ="Select * From rbook Order By rbook_register_date Desc"
if Request.QueryString("pageNo")="" then
PageNo=1
elseif IsNumeric(Request.QueryString("pageNo"))=false then
PageNo=1
else
PageNo=clng(Request.QueryString("pageNo"))
end if
Set rs=conn.execute(strSql)
if rs.recordcount=0 then
response.write "<script>alert('数据为空!');history.back();</script>"
response.end
end if
rs.pagesize=2
if PageNo<1 then
PageNo=1
end if
if PageNo>rs.pagecount then
PageNo=rs.pagecount
end if
rs.absolutepage=PageNo
i=0
do while i<rs.pagesize and not rs.eof
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CAD9EA">
<tr>
<td height="62" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="238" colspan="2" rowspan="12"><img src="<%=rs("rbook_image")%>" border="1" align="absmiddle" /></td>
</tr>
<tr>
<td width="116" height="40"><strong>书名 </strong></td>
<td width="189" height="40"><%=rs("rbook_name")%></td>
</tr>
<tr>
<td height="40"><strong>作者 </strong></td>
<td height="40"><%=rs("rbook_author")%></td>
</tr>
<tr>
<td height="40"><strong>出版社</strong></td>
<td height="40"><%=rs("rbook_publisher")%></td>
</tr>
<tr>
<td height="40"><strong>类型</strong></td>
<td height="40"><%=rs("rbook_type")%></td>
</tr>
<tr>
<td height="40"><strong>上传用户</strong></td>
<td height="40"><%=rs("rbook_user")%></td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="30" colspan="10"><div align="right">记录总数:<%=rs.recordcount%> 条 当前页:<%=PageNo%>/<%=rs.pagecount%> 页大小:<%=rs.pagesize%> <a href="?PageNo=1">首页</a> <a href="?PageNo=<%=PageNo-1%>">上页</a> <a href="?PageNo=<%=PageNo+1%>">下页</a> <a href="?PageNo=<%=rs.pagecount%>">末页</a> <input type=text id="goPage" value="<%=PageNo%>" size=2> <input type=button onclick="location='?PageNo='+document.all.goPage.value;" value="GO"></div></td>
</tr>
</table>
=================================================================
我帮你改一下
加入了翻页 等!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../include/conn.asp" -->
<%
Dim strSql,rs
strSql ="Select * From rbook Order By rbook_register_date Desc"
if Request.QueryString("pageNo")="" then
PageNo=1
elseif IsNumeric(Request.QueryString("pageNo"))=false then
PageNo=1
else
PageNo=clng(Request.QueryString("pageNo"))
end if
Set rs=conn.execute(strSql)
if rs.recordcount=0 then
response.write "<script>alert('数据为空!');history.back();</script>"
response.end
end if
rs.pagesize=2
if PageNo<1 then
PageNo=1
end if
if PageNo>rs.pagecount then
PageNo=rs.pagecount
end if
rs.absolutepage=PageNo
i=0
do while i<rs.pagesize and not rs.eof
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CAD9EA">
<tr>
<td height="62" colspan="4" align="center" valign="middle" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="238" colspan="2" rowspan="12"><img src="<%=rs("rbook_image")%>" border="1" align="absmiddle" /></td>
</tr>
<tr>
<td width="116" height="40"><strong>书名 </strong></td>
<td width="189" height="40"><%=rs("rbook_name")%></td>
</tr>
<tr>
<td height="40"><strong>作者 </strong></td>
<td height="40"><%=rs("rbook_author")%></td>
</tr>
<tr>
<td height="40"><strong>出版社</strong></td>
<td height="40"><%=rs("rbook_publisher")%></td>
</tr>
<tr>
<td height="40"><strong>类型</strong></td>
<td height="40"><%=rs("rbook_type")%></td>
</tr>
<tr>
<td height="40"><strong>上传用户</strong></td>
<td height="40"><%=rs("rbook_user")%></td>
</tr>
</table>
<%
rs.movenext
i=i+1
loop
%>
<table width="513" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="30" colspan="10"><div align="right">记录总数:<%=rs.recordcount%> 条 当前页:<%=PageNo%>/<%=rs.pagecount%> 页大小:<%=rs.pagesize%> <a href="?PageNo=1">首页</a> <a href="?PageNo=<%=PageNo-1%>">上页</a> <a href="?PageNo=<%=PageNo+1%>">下页</a> <a href="?PageNo=<%=rs.pagecount%>">末页</a> <input type=text id="goPage" value="<%=PageNo%>" size=2> <input type=button onclick="location='?PageNo='+document.all.goPage.value;" value="GO"></div></td>
</tr>
</table>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询