レイzero迅雷下载:asp如何分页

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 10:50:12
我一个非常做网站,但是好多搞不明白,请各位反指教。谢了

<table width=630 border=0>
<tr class=t1>
<td width=30 align=center bgcolor=#cccccc class=downbg>ID</td>
<td width=100 align=center bgcolor=#cccccc class=downbg>日期</td>
<td width=100 align=center bgcolor=#cccccc class=downbg>时间</td>
<td width=100 align=center bgcolor=#cccccc class=downbg>科室</td>
<td width=300 align=center bgcolor=#cccccc class=downbg>事项</td>
</tr>
<th height=10>
<%
if not isempty(request("page")) and request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
MaxPerPage=40
if zyy_key="" then
Set zyyyw=server.CreateObject ("adodb.recordset")
sql="select * from zyy order by zyy_id desc"
zyyyw.Open sql,conn,1,1
else
Set zyyyw=server.CreateObject ("adodb.recordset")
sql="select * from zyy where "&zyy_cond&" like '%"&zyy_key&"%' order by zyy_id desc"
zyyyw.Open sql,conn,1,1
end if
if not zyyyw.EOF then
zyyyw.PageSize=maxperpage
mpage=zyyyw.PageCount
totalput=zyyyw.RecordCount
if currentpage<1 then
currentpage=1
end if
zyyyw.Move (currentpage-1)*maxperpage
end if
if zyyyw.EOF and zyyyw.bof then
response.Write ("暂时没有记录!")
%>
<%
else
k=(totalput-maxperpage*(currentpage-1))+1
do while not zyyyw.EOF
k=k-1
ii=ii+1
%>

<tr class=t2><td width=30 class=downbg align=center><%=zyyyw("zyy_id")%></td>
<td width=100 class=downbg align=center><%=zyyyw("zyy_date")%></td>
<td width=100 class=downbg align=center><%=zyyyw("zyy_time")%></td>
<td width=100 class=downbg><%=zyyyw("zyy_room")%></td>
<td width=300 class=downbg><%=zyyyw("zyy_work")%></td></tr>

<% i=i+1
if i>=maxperpage then exit do
zyyyw.MoveNext
loop
end if
%>

</table>
<table width=630 border=0>
<tr><td width=370 align=center class=t2>
<form name="form1" method="post" action="index.asp">
<table width=98% border="0" class=t2>
<tr>
<td>请输入日期(格式:2006-04):<input name="key" type="text" id="key" size="10">
按 <select name="cond" id="cond">
<option value="zyy_date" selected>日期</option>
</select><input type="submit" name="Submit" value="查询"></td></tr></table>
</form>
</td>
<td width=260 align=center class=t2>
<a class=a1 href="javascript:location.reload()">刷新</a> 记录总数:<%=zyyyw.recordcount%> 每页<%=MaxPerPage%>条
<%pageno=currentPage%>
<%if cint(pageno)>1 then%>
<a href="?page=1" title="最前页">
<%end if%>
<font face="Webdings">9</font></a> 
<%if cint(pageno)>1 then%>
<a href=?page=<%=pageno-1%> title="上一页">
<%end if%>
<font face="Webdings">7</font></a>
<%if cint(pageno)< mpage then%>
<a href=?page=<%=pageno+1%> title="下一页">
<%end if%>
<font face="Webdings">8</font></a> 
<%if cint(pageno)< mpage then%>
<a href="?page=<%=mpage%>" title="最后页">
<%end if%>
<font face="Webdings">:</font></a>

</td>
</tr>
</table>

’做好数据库连接后,直接插入下列代码,稍微修改即可,把红色字符替换即可
<%
Dim i,intPage,page,pre,last,filepath
set conn = server.createobject("adodb.connection")
conn.open 数据库连接字符串

set RS1=server.CreateObject("adodb.Recordset")
sql="SELECT * FROM 数据库表名"

RS1.PageSize = 15
RS1.CursorLocation = 3
RS1.Open sql,conn,0,2,

if RS_Computer.PageCount<>0 then
%>
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) >= RS1.PageCount then
intpage = RS1.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not RS1.eof then
RS1.AbsolutePage = intpage
end if

for i=1 to RS1.PageSize
if RS1.EOF or RS1.BOF then exit for
%>

'要显示的内容....
<%
RS1.movenext
next
%><table width="558" border="1" align="center" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff >
<tr>
<%if RS1.pagecount > 0 then%>
<td width="180" align="left">当前页<%=intpage%>/<%=RS1.PageCount%></td>
<%else%>
<td width="100" align="left">当前页0/0</td><%end if%>
<td width="240" align="right"> <a href=页面名称.asp?page=1>首页</a>|
<%if pre then%>
<a href=页面名称.asp?page=<%=intpage -1%>>上页</a>| <%end if%>
<%if last then%>
<a href=页面名称.asp?page=<%=intpage +1%>>下页</a> |<%end if%>
<a href=页面名称.asp?page=<%=RS1.PageCount%>>尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to RS1.PageCount
if i = intpage then%>
<option value="页面名称.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="页面名称.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>

<%else%>
<table width="560" align="center">
<tr>
<td><%response.Write("对不起,未发现相关数据")%></td>
</tr>
</table>
<%end if%>