标题: 分页问题? [打印本页] 作者: 成熟之惑 时间: 2010-1-7 07:05 标题: 分页问题? <%text1=Request("text1") %>
<%text2=Request("text2") %>
<%text3=Request("text3") %>
<%
if text1<>""or text2<>"" or text3<>"" then
%>
<%
set conn=server.createobject("adodb.connection")
conn.open="driver={sql server};server=127.0.0.1;uid=sa;pwd=;database=tjphone"
sql="select * from tianjin where chanpin like " & "'%" &text1& "%'" & " and xingzhi like " & "'%" &text2& "%'" &"and lxdd like " & "'%" &text3& "%'"
set rs=Server.CreateObject("ADODB.recordset")
rs.open sql,conn,3
%>
<%
sub showonepage(rs,page)
rs.absolutepage=page
for kpage=1 to rs.pagesize
while not rs.eof
row="<tr align=middle>"
for i=0 to rs.fields.count-1
row=row&"<td>"&rs(i)&"</td>"
next
Response.Write row&"</tr>"
rs.movenext
if rs.eof then exit for
wend
%>
<%
next
end sub
%>
<% rs.pagesize=5
page=1
page=clng(request("page"))
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
showonepage rs,page
%>
<% if page<>1 then%>
<a href="xun.asp?page=1">第一页</a><a href="xun.asp?page=<%=(page-1)%>">上一页</a>
<% end if%>
<% if page<>rs.pagecount then%>
<a href="xun.asp?page=<%=(page+1)%>">下一页</a><a href="xun.asp?page=<%=rs.pagecount%>">最后一页</a>
<% end if%>
<%
end if
%>
查询后的数据为什么不是5页一翻的,谢谢高手门.作者: 渴望光明 时间: 2010-1-7 07:05
问题:查询出来的数据全部的显示,而不是5个一翻页.作者: 孤独与夜缠绵 时间: 2010-1-7 07:05
要说明出了什么问题啊作者: 我只在乎你 时间: 2010-1-7 07:05
求助啊作者: 小点点14504 时间: 2010-1-7 07:05
<!--#include file="../conn/conn.asp"-->
<!--#include file="../common/common.asp"-->
<%
'创作时间:<fc:date>
'作者:yxl
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>asp-列表</title>
<link href="../style/style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../js/function.js"></script>
</head>
<body class="mainBody">
<form name='form1' action='dict_loveQuery.asp' method='post'>
<table border='0' cellspacing='0' cellpadding='0' width='90%' align='center' height='25'>
<tr>
<td width='20%'>
<input type='button' class='butInput' name='butAdd' value='新增' onclick = "location.href='dict_loveNew.asp'">
</td>
</tr>
</table>
<table class='tblBorder' cellspacing='1' cellpadding='5' width='90%' border='0' align='center'>
<tr class='tblTitle'>
<td colspan="6">≡ 列表 ≡</td>
</tr>
<tr class="tblHead">
<td> </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td width='6%' align="center">操作</td>
</tr>
<tr>
<%
sql = "select * from dict_love where 1=1 "
set rs = server.createObject("adodb.recordset")
if request("page")<>"" then
curpage=cint(request("page"))'当前是第几页
else
curpage=1
end if
rs.open sql,conn,3,3
pages = 1
If not (rs.bof or rs.eof) then
rs.PageSize = 10一页几条记录
pages = rs.pagecount总页数
recordCount = rs.recordCount总记录数
if (curpage-1) * rs.pagesize < recordcount then游标位置
rs.move (curpage-1) * rs.PageSize
showcontent
else
showcontent
end if
end if
call closeRs(rs)
closeConn
sub showcontent()
do while not (rs.eof or err)
i = i +1
if i mod 2 =0 then
trStyle = "tblRow2"
else
trStyle = "tblRow1"
end if
id = rs("id")
name = rs("name")
flag = rs("flag")
orders = rs("orders")
%>
<tr class="<%=trStyle%>">
<td width="1"><input type="checkbox" name="" value="<%=rs("")%>"></td>
<td><%=id%></td>
<td><%=name%></td>
<td><%=flag%></td>
<td><%=orders%></td>
<td align='center'><a href="dict_loveModify.asp?=<%=rs("")%>" class="fun">修改</a></td>
</tr>
<%
j=j+1
if j >= rs.PageSize Then exit do
rs.movenext
loop
end sub
%>
</table>
<table border='0' cellspacing='0' cellpadding='1' width='90%' align='center'>
<tr>
<td height='25'>
<input type='button' class='butInput' name='butSelectAll' value='全部选择' onclick = "selectAllCheck('',true)">
<input type='button' class='butInput' name='butCancleSelect' value='取消选择' onclick="selectAllCheck('',false)">
<input type='button' class='butInput' name='butDel' value=' 删除 ' onclick="executeBut(form1,'dict_loveDel.asp','','请选择要删除的记录!','确定要删除选择的记录!')">
</td>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align='right'>
<%
if curpage<>1 then
response.write "<a href=dict_loveList.asp class='pagebreak'>第一页</A>"
response.write "<a href=dict_loveList.asp?page=" & (curpage - 1) & " class='pagebreak'>上一页</A> "
end if
if curpage<>pages then
response.write "<a href=dict_loveList.asp?page=" & (curpage + 1) & " class='pagebreak'>下一页</A> "
response.write "<a href=dict_loveList.asp?page=" & pages & " class='pagebreak'>最后一页</A> "
end if
%>
<font color="#000000">第</font> <font color="#FF0000"><%=curpage%></font>
<font color="#000000">页,共</font> <font color="#FF0000"><%=pages%></font>
页
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>