ASP记录集分页显示
<%setrsExamination=server.createobject("adodb.recordset")sqlExamination="select*fromE...
<%
set rsExamination=server.createobject("adodb.recordset")
sqlExamination = "select * from Examination "
rsExamination.open sqlExamination,conn,1,1
%>
<br>
<table width="784" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
<tr>
<td width="172" align="center" bgcolor="#609B95" class="l11">日期</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">房号</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">姓名</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">性别</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">证件号码</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">电脑类型</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">进入时间</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">离去时间</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">批准人</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">备注</td>
<td width="53" align="center" bgcolor="#609B95" class="l11">操作</td>
</tr>
<% if rsExamination.eof then %>
<% else %>
<% do while not rsExamination.eof %>
<tr>
<td height="15" align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("Examine_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("class")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text2")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("sex")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text4")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text5")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("come_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("out_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text8")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text9")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><strong><a href="admin_tjcomputer_del.asp?id=<%=rsExamination("id")%> "><img src="image/a_delete.gif" alt="删除" width="58" height="15" border="0" /></a></strong></td>
</tr>
<% rsExamination.movenext %>
<% loop %>
<% end if %>
<% rsExamination.close%>
<%set rsExamination = nothing %>
</table> </td>
</tr>
</table>
2楼的 用了你的代码 出现错误哦
错误类型:
Microsoft VBScript 编译器错误 (0x800A0408)
无效字符
/毕业设计/admin_tjcomputer.asp, line 141, column 16
dim currentpage(当前页面),totalput(信息总条数),totalpage(总页数)
---------------^ 展开
set rsExamination=server.createobject("adodb.recordset")
sqlExamination = "select * from Examination "
rsExamination.open sqlExamination,conn,1,1
%>
<br>
<table width="784" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
<tr>
<td width="172" align="center" bgcolor="#609B95" class="l11">日期</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">房号</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">姓名</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">性别</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">证件号码</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">电脑类型</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">进入时间</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">离去时间</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">批准人</td>
<td width="57" align="center" bgcolor="#609B95" class="l11">备注</td>
<td width="53" align="center" bgcolor="#609B95" class="l11">操作</td>
</tr>
<% if rsExamination.eof then %>
<% else %>
<% do while not rsExamination.eof %>
<tr>
<td height="15" align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("Examine_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("class")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text2")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("sex")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text4")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text5")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("come_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("out_time")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text8")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><%=rsExamination("text9")%></td>
<td align="center" bgcolor="#FFFFFF" class="p12"><strong><a href="admin_tjcomputer_del.asp?id=<%=rsExamination("id")%> "><img src="image/a_delete.gif" alt="删除" width="58" height="15" border="0" /></a></strong></td>
</tr>
<% rsExamination.movenext %>
<% loop %>
<% end if %>
<% rsExamination.close%>
<%set rsExamination = nothing %>
</table> </td>
</tr>
</table>
2楼的 用了你的代码 出现错误哦
错误类型:
Microsoft VBScript 编译器错误 (0x800A0408)
无效字符
/毕业设计/admin_tjcomputer.asp, line 141, column 16
dim currentpage(当前页面),totalput(信息总条数),totalpage(总页数)
---------------^ 展开
3个回答
展开全部
要做到分页的话 :
1、在<%else%>这里加上
<%else
dim currentpage(当前页面),totalput(信息总条数),totalpage(总页数)
currentpage=request("page") 'page 为传递过来的页面,看了下面就明白了
if currentpage="" then
currentpage=1
end if
rs.absolutepage=currentpage
rs.pagesize=10 '定义每页显示的信息条书,也就是多少条<tr></tr>
totalput=rs.recordcount '记录集中的信息总数
totalpage=rs.pagecount '总页数
dim i
i=1
%>
然后再rs.movenext 这一句前加上
i=i+1
if i>rs.pagezie then
exit do
rs.movenext
loop
以下是分页显示,放在你想显示分页的地方
<%dim p
for p=1 to totalpage
if cint(p)=cint(currentpage) then
response.Write "<b>"&i&"</b> "
else
response.Write "<a href=?page="&p&">"&p&"</a> "
end if
next
%> 显示的效果就是 1 2 3 4
如果你想显示 首页 上一页 下一页 尾页 转到** 页 的话 代码是这样的
<%if currentpage=1 then
response.Write "<font color='#666666'>无上页</font> "
else %>
<a href="product.asp?page=1">首页</a> <a href="product.asp?page=<%=currentpage-1%>">上一页</a>
<%end if
if totalpage<currentpage+1 then
response.Write "<font color='#666666'>无下页</font> "
else %>
<a href="product.asp?page=<%=currentpage+1%>">下一页</font></a> <a href="product.asp?page=<%=totalpage%>">尾页</a>
<%end if%>
第 <b> <%=currentpage%> </b>页 共 <b> <%=totalpage%> </b>页 共<b> <%=totalput%> </b>个产品 每页 <b><%=rs.pagesize%></b> 个
转到:<select name="page" onChange="javascript:location.href=this.options[selectedIndex].value">
<% dim r
for r=1 to totalpage
if Cint(r)=Cint(currentpage) then
%>
<option value="product.asp?page=<%=r%>" selected="selected">第<%=r%>页</option>
<%else%>
<option value="product.asp?page=<%=r%>">第<%=r%>页</option>
<%end if
next%>
</select>
1、在<%else%>这里加上
<%else
dim currentpage(当前页面),totalput(信息总条数),totalpage(总页数)
currentpage=request("page") 'page 为传递过来的页面,看了下面就明白了
if currentpage="" then
currentpage=1
end if
rs.absolutepage=currentpage
rs.pagesize=10 '定义每页显示的信息条书,也就是多少条<tr></tr>
totalput=rs.recordcount '记录集中的信息总数
totalpage=rs.pagecount '总页数
dim i
i=1
%>
然后再rs.movenext 这一句前加上
i=i+1
if i>rs.pagezie then
exit do
rs.movenext
loop
以下是分页显示,放在你想显示分页的地方
<%dim p
for p=1 to totalpage
if cint(p)=cint(currentpage) then
response.Write "<b>"&i&"</b> "
else
response.Write "<a href=?page="&p&">"&p&"</a> "
end if
next
%> 显示的效果就是 1 2 3 4
如果你想显示 首页 上一页 下一页 尾页 转到** 页 的话 代码是这样的
<%if currentpage=1 then
response.Write "<font color='#666666'>无上页</font> "
else %>
<a href="product.asp?page=1">首页</a> <a href="product.asp?page=<%=currentpage-1%>">上一页</a>
<%end if
if totalpage<currentpage+1 then
response.Write "<font color='#666666'>无下页</font> "
else %>
<a href="product.asp?page=<%=currentpage+1%>">下一页</font></a> <a href="product.asp?page=<%=totalpage%>">尾页</a>
<%end if%>
第 <b> <%=currentpage%> </b>页 共 <b> <%=totalpage%> </b>页 共<b> <%=totalput%> </b>个产品 每页 <b><%=rs.pagesize%></b> 个
转到:<select name="page" onChange="javascript:location.href=this.options[selectedIndex].value">
<% dim r
for r=1 to totalpage
if Cint(r)=Cint(currentpage) then
%>
<option value="product.asp?page=<%=r%>" selected="selected">第<%=r%>页</option>
<%else%>
<option value="product.asp?page=<%=r%>">第<%=r%>页</option>
<%end if
next%>
</select>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个分页有点简单
<%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
sql="select * from user order by user_ID desc"
rs.PageSize = 20
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<!--循环开始-->
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>
<!-- ..................
要循环显示的内容................-->
<%
rs.movenext
next
%>
<!--循环体结束
分页部分:-->
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="?page=1">首页</a>|
<%if pre then%>
<a href="?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>
</table>
<%
dim i,intPage,page,pre,last,filepath
set rs = server.CreateObject("adodb.recordset")
sql="select * from user order by user_ID desc"
rs.PageSize = 20
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<!--循环开始-->
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>
<!-- ..................
要循环显示的内容................-->
<%
rs.movenext
next
%>
<!--循环体结束
分页部分:-->
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="?page=1">首页</a>|
<%if pre then%>
<a href="?page=<%=intpage -1%>">上页</a>| <%end if%>
<%if last then%>
<a href="?page=<%=intpage +1%>">下页</a> |<%end if%>
<a href="?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询