asp查询结果中翻页问题,有编码

<body><!--#includefile="conn.asp"--><%dimdanwei,chehao,chehao1,chehao2danwei=request.... <body>
<!--#include file="conn.asp"-->
<%
dim danwei,chehao,chehao1,chehao2
danwei=request.Form("select1")
chehao1=request.Form("zj")
chehao2=request.Form("chehao")
chehao=chehao1&chehao2
if danwei="" and chehao2="" then
response.Write("<center>")
response.Write("查询条件不能为空  <a href=javascript:history.back()>返回</a>")
response.Write("</center>")
response.end
end if
if danwei<>"" and chehao2<>"" then
response.Write("<center>")
response.Write("按单位查询和按车号查询不能同时使用  <a href=javascript:history.back()>返回</a>")
response.Write("</center>")
response.end
end if
if danwei="" then
strsql="select * from cardata where carno='" & chehao & "'"
else
strsql="select * from cardata where unit='" & danwei & "'"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open strsql,conn,3,1
rs.pagesize=15 '每页显示15条

nextpage=request.form("nextpage")if nextpage="" then
session("abspage")=1
else
if nextpage="上一页" then
session("abspage")=session("abspage")-1
elseif nextpage="下一页" then
session("abspage")=session("abspage")+1
elseif nextpage="第一页" then
session("abspage")=1
elseif nextpage="最后一页" then
session("abspage")=rs.pagecount
end if
rs.absolutepage=session("abspage")
end if

if rs.recordcount>0 then
i=0
response.write "<table border=1 width=100%/>"
response.write "<tr><td colspan=8 align=center>"
response.write "这是第" & session("abspage") & "页" & " 共有" & rs.recordcount & "个主题"
response.write "</tr>"
%>
<tr>
<td align=center width=10%>序号</td>
<td align=center width=10%>车号</td>
<td align=center width=20%>使用单位</td>
<td align=center width=10%>车型</td>
<td align=center width=20%>厂牌</td>
<td align=center width=10%>登记日期</td>
<td align=center width=10%>现状</td>
<td align=center width=10%>详细信息</td>
</tr>
<%
do while not rs.eof and i<15
%>
<tr>
<td align=center><%=rs.absoluteposition%></td>
<td><%=rs("carno")%></td>
<td align="left"><%=rs("unit")%><%=rs("nextunit")%></td>
<td align=center><%=rs("mode")%></td>
<td align=center><%=rs("type")%></td>
<td align=center><%=rs("usertime")%></td>
<td align=center><%=rs("status")%></td>
<td align=center><a href=carinfo2.asp?id=<%=rs("id")%>>详细信息</a></td>
</tr>
<%rs.movenext
i=i+1
loop
response.write "</table></center>"
response.write "<center><form action=carinfo.asp method=post>"
if rs.pagecount>1 then
response.write "<input type=submit value=上一页 name=nextpage>"&" "
end if
if(session("abspage"))<rs.pagecount then
response.write "<input type=submit value=下一页 name=nextpage>"
end if
'end if
response.write "</form>"
else
response.Write("<center>")
response.Write("无查询结果  <a href=javascript:history.back()>返回</a>")
response.Write("</center>")
response.end
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</body>
</html>
展开
 我来答
guofengqiu
2010-02-21 · TA获得超过105个赞
知道小有建树答主
回答量:233
采纳率:0%
帮助的人:132万
展开全部
去下载一个分页源码改一下。

或者改一下我下面这个也行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db_sousuo1.mdb")
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table width="535" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="200" valign="top">
<%
dim rs,sql
set rs=server.CreateObject("adodb.recordset")

sql="select * from product where "

if trim(request("bt"))<>"" then
sql= sql & "carclass like '%"&trim(request("bt"))&"%' and "
end if

if trim(request("nr"))<>"" then
sql= sql & "provice like '%"&trim(request("nr"))&"%' and "
end if

if trim(request("fbz"))<>"" then
sql= sql & "provice_shi like '%"&trim(request("fbz"))&"%' and "
end if
sql= sql & " 1=1 "
rs.open sql,conn,1
if rs.bof or rs.eof then
response.write "对不起,没有符合查询条件的学生信息!"
else
dim page
page=Clng(request("page"))
rs.pagesize=20
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
rs.Absolutepage=page
%>
<%
for i=1 to rs.pagesize
%>
<table height=24 cellspacing=0 cellpadding=0 width=535 border=0>
<tbody>
<tr bgcolor="#f7f7f7" onmouseover="this.bgColor='#e8e8e8';" onmouseout="this.bgColor='#f7f7f7';">
<td height="25" align="left"><%=i%>. <%=rs("carclass")%></td>
</tr>
</tbody>
</table>
<%
rs.movenext
if rs.eof then exit for
next
end if
%></td>
</tr>
<tr>
<td>
<form name="form1" method="get" action="news.asp">
<%
Response.write "<span class='style1'>共找到</span>" & "<span class='style1'><font color='#FF0000'>" & Cstr(rs.RecordCount) & "</font></span>" & "<span class='style1'>名学生</span>  "
if page<>1 then
response.write "<span class='style1'><a href=news.asp?page=1>首页</a> </span>"
response.write "<span class='style1'><a href=news.asp?page="&(page-1)&">上一页</a></span> "
end if
if page<>rs.pagecount then
response.write "<span class='style1'><a href=news.asp?page="&(page+1)&">下一页</a> </span>"
response.write "<span class='style1'><a href=news.asp?page="&rs.pagecount&">尾页</a> </span>"
end if
%>
<span class='style1'>第<font color='#FF0000'><%=page%></font>页/共<font color='#FF0000'><%=rs.pagecount%></font>页  </span>
<input name="page" size="2" value="<%=page%>">
<INPUT id=image type=image src="images/go.gif" border=0>
</form>
</td>
</tr>
</table>

</body>
</html>
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式