ASP分页难题求解 ,搜索结果点"下一页"却显示全部记录???详细给高分>>
<%
keys=request.form( "key ")
set conn=server.createobject( "adodb.connection ")
conn.open "driver={microsoft access driver (*.mdb)};dbq= "&server.mappath( "phone.mdb ")
exec= "select * from bill where phone like '% "&keys& "% ' or phone2 like '% "&keys& "% ' "
set rs=server.CreateObject( "adodb.recordset ")
rs.open exec,conn,1,1
set rs1=server.CreateObject( "adodb.recordset ")
sql= "SELECT sum(Bill.charge) as www FROM Bill WHERE phone like '% "&keys& "% ' "
rs1.open sql,conn,1,1
rs.pagesize=20
zongye=rs.pagecount
page=int(request( "page "))
if page <=0 then page=1
if request( "page ")= " " then page=1
rs.absolutepage=page
%>
<html>
<head>
<title> 话费查询 </title>
</head>
<body bgcolor= "#FFFFFF " text= "#000000 " topmargin= "20 " bottommargin= "0 ">
<table border= "0 " width= "100% " id= "table1 " bgcolor= "#D5EAFD ">
<tr>
<td width= "167 "> 您查询的分机号码是: </td>
<td width= "276 "> <%response.write(keys) %> </td>
<td width= "90 "> 话费总计: </td>
<td> <%= rs1( "www ") %> </td>
</tr>
</table>
<table width= "100% " border= "1 " cellpadding= "0 " cellspacing= "0 ">
<p>
<tr>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打日期 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打时间 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 通话时长 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 通话费用 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打类型 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 机主姓名 </td>
<td height= "31 " bgcolor= "#F7F7F7 "> 部门 </td>
</tr>
<%
if rs.eof or rs.bof then
response.write( "没有找到记录! ")
else
for i=1 to rs.pagesize
%>
</p>
<tr>
<td width= "10% "> <%=rs( "startdate ")%> </td>
<td width= "10% "> <%=rs( "starttime ")%> </td>
<td width= "10% "> <%=rs( "duration ")%> </td>
<td width= "10% "> <%=rs( "charge ")%> </td>
<td width= "15% "> <%=rs( "destination ")%> </td>
<td width= "10% "> <%=rs( "username ")%> </td>
<td> <%=rs( "department ")%> </td>
</tr>
<%
rs.movenext
next
end if
%>
</table>
<br>
<% if page=1 and not page=zongye then %>
第一页 | 上一页 |
<a href= "index.asp?page= <%=page+1%> "> 下一页 </a> |
<a href= "index.asp?page= <%=zongye%> "> 最后页 </a>
<% elseif page <> 1 and not page =zongye then%>
<a href= "index.asp?page=1 "> 第一页 </a> |
<a href= "index.asp?page= <%=page-1%> "> 上一页 </a> |
<a href= "index.asp?page= <%=page+1%> "> 下一页 </a> |
<a href= "index.asp?page= <%=zongye%> "> 最后页 </a> |
<% elseif page=zongye then %>
<a href= "index.asp?page=1 "> 第一页 </a>
<a href= "index.asp?page= <%=page-1%> "> 上一页 </a> |
下一页|
最后页|
<% end if %>
<br>
<table border= "0 " width= "100% " id= "table1 " bgcolor= "#D5EAFD " height= "31 ">
<tr>
<td width= "591 "> </td>
<td>
</td>
</tr>
</table>
</body>
</html>
[解决办法]
<%
keys=request( "key ")
set conn=server.createobject( "adodb.connection ")
conn.open "driver={microsoft access driver (*.mdb)};dbq= "&server.mappath( "phone.mdb ")
exec= "select * from bill where phone like '% "&keys& "% ' or phone2 like '% "&keys& "% ' "
set rs=server.CreateObject( "adodb.recordset ")
rs.open exec,conn,1,1
set rs1=server.CreateObject( "adodb.recordset ")
sql= "SELECT sum(Bill.charge) as www FROM Bill WHERE phone like '% "&keys& "% ' "
rs1.open sql,conn,1,1
rs.pagesize=20
zongye=rs.pagecount
page=int(request( "page "))
if page <=0 then page=1
if request( "page ")= " " then page=1
rs.absolutepage=page
%>
<html>
<head>
<title> 话费查询 </title>
</head>
<body bgcolor= "#FFFFFF " text= "#000000 " topmargin= "20 " bottommargin= "0 ">
<table border= "0 " width= "100% " id= "table1 " bgcolor= "#D5EAFD ">
<tr>
<td width= "167 "> 您查询的分机号码是: </td>
<td width= "276 "> <%response.write(keys) %> </td>
<td width= "90 "> 话费总计: </td>
<td> <%= rs1( "www ") %> </td>
</tr>
</table>
<table width= "100% " border= "1 " cellpadding= "0 " cellspacing= "0 ">
<p>
<tr>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打日期 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打时间 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 通话时长 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 通话费用 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 拨打类型 </td>
<td width= "10% " height= "31 " bgcolor= "#F7F7F7 "> 机主姓名 </td>
<td height= "31 " bgcolor= "#F7F7F7 "> 部门 </td>
</tr>
<%
if rs.eof or rs.bof then
response.write( "没有找到记录! ")
else
for i=1 to rs.pagesize
%>
</p>
<tr>
<td width= "10% "> <%=rs( "startdate ")%> </td>
<td width= "10% "> <%=rs( "starttime ")%> </td>
<td width= "10% "> <%=rs( "duration ")%> </td>
<td width= "10% "> <%=rs( "charge ")%> </td>
<td width= "15% "> <%=rs( "destination ")%> </td>
<td width= "10% "> <%=rs( "username ")%> </td>
<td> <%=rs( "department ")%> </td>
</tr>
<%
rs.movenext
next
end if
%>
</table>
<br>
<% if page=1 and not page=zongye then %>
第一页 | 上一页 |
<a href= "index.asp?key= <%=keys%> &page= <%=page+1%> "> 下一页 </a> |
<a href= "index.asp?key= <%=keys%> &page= <%=zongye%> "> 最后页 </a>
<% elseif page <> 1 and not page =zongye then%>
<a href= "index.asp?key= <%=keys%> &page=1 "> 第一页 </a> |
<a href= "index.asp?key= <%=keys%> &page= <%=page-1%> "> 上一页 </a> |
<a href= "index.asp?key= <%=keys%> &page= <%=page+1%> "> 下一页 </a> |
<a href= "index.asp?key= <%=keys%> &page= <%=zongye%> "> 最后页 </a> |
<% elseif page=zongye then %>
<a href= "index.asp?key= <%=keys%> &page=1 "> 第一页 </a>
<a href= "index.asp?key= <%=keys%> &page= <%=page-1%> "> 上一页 </a> |
下一页|
最后页|
<% end if %>
<br>
<table border= "0 " width= "100% " id= "table1 " bgcolor= "#D5EAFD " height= "31 ">
<tr>
<td width= "591 "> </td>
<td>
</td>
</tr>
</table>
</body>
</html>