类型:转载 责任编辑:asp 日期:2007/03/01
本来共有10页记录,我按条件搜索到只有2页,我点第2页时就返回未分页状态了。是我的分页哪里没有参数,请帮忙加上,谢谢!在线等待......
<!--#include file="conn.asp"-->
<%
response.expires = 0
************** 关闭数据连接 **************
function closedatabase
conn.close
set conn = nothing
end function
search=trim(request("t1"))
if search<>empty thena
sel=request("sel")
if sel="k1" then
sql="select id,k1,k2,k3 from client where k1 like %"&search&"% order by id desc"
else
sql="select id,k1,k2,k3 from client where k2 like %"&search&"% order by id desc"
end if
else
sql="select id,k1,k2,k3 from client order by id desc"
end if
rs.open sql,conn,1,1
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>浏览客户资料</title>
<style type="text/css">
<!--
body {
font-family: "宋体";
font-size: 12px;
}
table {
font-family: "宋体";
font-size: 12px;
}
-->
</style>
<style type="text/css">
<!--
a:link {
font-family: "宋体";
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:visited {
font-family: "宋体";
font-size: 12px;
color: #000000;
text-decoration: none;
}
a:hover {
font-family: "宋体";
font-size: 12px;
color: #993300;
text-decoration: none;
}
a:active {
font-family: "宋体";
font-size: 12px;
color: #000000;
text-decoration: none;
}
-->
</style>
<link href="css/button1.css" rel="stylesheet" type="text/css">
<link href="css/text6.css" rel="stylesheet" type="text/css">
<link href="css/font.css" rel="stylesheet" type="text/css">
</head>
<body background="image/background.gif">
<%
---------------------------------------开始分页程序
const filename = "index.asp"此文件的文件名
const sizepage = 20设置每页记录数
const dispage = 10设置页面上显示多少页
if rs.eof and rs.bof then%>
<div align="center"> <br>
<font color="#ff0033">目前没有任何记录!请点击<a href="add_client.asp">“新增客户”</a>资料。或是搜索到没有资料,请点击<a href="index.asp">“返回”</a>。</font></div>
<%else
rs.pagesize = sizepage
dim totalpages
totalpages = rs.pagecount
if not isnumeric(request.querystring("curpage")) or request.querystring("curpage") = "" then
curpage = 1
elseif cdbl(request.querystring("curpage")) > totalpages then
curpage = totalpages
else
curpage = cint(request.querystring("curpage"))
end if
rs.absolutepage=curpage
rs.cachesize = rs.pagesize设置最大记录数
dim totalcount
totalcount =rs.recordcount
startpagenum=1
do while startpagenum+dispage<=curpage
startpagenum=startpagenum+dispage
loop
endpagenum=startpagenum+dispage-1
if endpagenum>rs.pagecount then endpagenum=rs.pagecount%>
<table width="600" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999">
<tr>
<td bgcolor="#eef1ff"> <div align="center">公司名称</div></td>
<td bgcolor="#eef1ff"> <div align="center"></div>
<div align="center">创建人</div></td>
<td bgcolor="#eef1ff"><div align="center">权属</div></td>
<td colspan="4" bgcolor="#eef1ff"><div align="center">客户操作</div></td>
</tr>
<%i=0
p=rs.pagesize*(curpage-1)
do while (not rs.eof) and (i<rs.pagesize)
p=p+1%>
<tr bgcolor="#ffffff">
<td> <div align="center"><%=rs(1)%></div></td>
<td> <div align="center"><%=rs(2)%></div></td>
<td><div align="center"><%=rs(3)%></div></td>
<td width="50">
<div align="center"><a href="add_thing.asp?id=<%=rs(0)%>">增加事件</a></div></td>
<td width="50">
<div align="center"><a href="client_detail.asp?id=<%=rs(0)%>">详细资料</a></div></td>
<td width="50">
<div align="center"><a href="modify_client.asp?id=<%=rs(0)%>">修改资料</a></div></td>
<td width="50">
<div align="center">
<p><a href="del_client.asp?id=<%=rs(0)%>" title="想清楚哦!">删除</a></p>
</div></td>
</tr>
<%i=i+1
rs.movenext
loop%>
</table>
<table width="600" align="center" cellpadding="5">
<form name="form2" method="post" action="index.asp" onsubmit="return check_form()">
<tr>
<td width="146"><div align="left"><a href="add_client.asp"><img src="image/topnew.gif" width="23" height="12" border="0">新增客户资料</a></div></td>
<td width="426"><img src="image/search.gif" width="16" height="16">搜索
<input name="t1" type="text" class="text6">
<select name="sel" class="font" onchange="submit()" on>
<option>请选择条件</option>
<option value="k1">公司名称</option>
<option value="k2">创建人</option>
</select>
『<a href="search.asp">高级搜索</a>』</td>
</tr>
</form>
</table>
<table width="600" border="0" align="center" cellspacing="1">
<form name="form1" method="get" action="<%=filename%>">
<tr>
<td width="36%" height="20">页次:<b><font color="#ff0000"><%=curpage%></font>/<%=totalpages%></b> 每页<b><%=sizepage%></b> 总记录数<b><%=rs.recordcount%></b></td>
<td>
<div align="right">分页:
<%if curpage>dispage then%>
<a href="<%=filename%>?curpage=1"><font face=webdings title="首页">9</font></a>
<%end if%>
<%if curpage>dispage then%>
<a href="<%=filename%>?curpage=<%=startpagenum-1%>"><font face=webdings title="上<%=dispage%>页">7</font></a>
<%end if
for i=startpagenum to endpagenum
if i<>curpage then %>
<a href="<%=filename%>?curpage=<%=i%>"><b><%=i%></b></a>
<% else %>
<font color="#ff0000"><b><%=i%></b></font>
<% end if
next %>
<% if endpagenum<rs.pagecount then %>
<a href="<%=filename%>?curpage=<%=endpagenum+1%>"><font face=webdings title="下<%=dispage%>页">8</font></a>
<%end if
if curpage<totalpages then%>
<a href="<%=filename%>?curpage=<%=totalpages%>"><font face=webdings title="尾页">:</font></a>
<%end if%>
转到:
<input name="curpage" type="text" id="curpage" value="<%=curpage%>" size="3" maxlength="10">
<input name="submit" type="submit" class="button1" value="go">
</div></td>
</tr>
</form>
</table>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>
推荐阅读
没人比如我来比如:上面几位的说法:
比如:
<% if page>1 then %> <a href="../zhuangbei/mysearch.asp?page=<%=page-1%>&clb2=<%=clb2%>&province=<%=province%>&city=<%=city%>">上一页</a><%end if%>
问号后面接着查询条件,和页数
然后在程序的开始
在取得:
page=request("page")
clb2=request("clb2")
..
关于分页,看看这贴
http://expert.csdn.net/expert/topic/1449/1449960.xml?temp=.8001367
傳遞參數方法:
<form name="form1">
<input type="hidden" name="名稱" value="<%=aaa%>">
</form>
//aaa為參數的值.