前后翻滚10页的实现

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

<%

set con=server.CreateObject("ADODB.Connection")

strConnection="Data Source=xxxxxxx;"

con.Open strConnection

set rs = Server.CreateObject("ADODB.Recordset")

chartSQL="select ID,name,category_one from goods "

rs.Open chartSQL,con,1,3

if rs.EOF or rs.BOF then '如果为空

response.end

end if

pagesize=10 '每页显示10条记录

pagecuont=rs.PageCount '总页数

recordcount=rs.RecordCount

dim pagenum '当前页码

dim currentRecord '当前页的记录数,对于末页其值不等于pagesize

if Request.QueryString ("pageNum")="" then

pageNum=1

else

pageNum=Request.QueryString ("pageNum")

rs.AbsolutePage =trim(Request.QueryString ("pageNum"))

end if

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 1</title>

<SCRIPT LANGUAGE=javascript>

<!--

function openwindow(url){

window.open(url,'','resizable=no,width=240,height=160,fullscreen=yes')

}

//-->

</SCRIPT>

<link rel="stylesheet" href="file:///F|/mysourceof17560/CSS.CSS" type="text/css">

</head>

<body bgcolor=#999999>

<p align="center">商品修改页面</p>

<table border="1" width="100%" cellpadding="0" cellspacing="0" bordercolordark="#999999" bordercolorlight="#000000">

<tr>

<td width="10%">

<div align="center">编号</div>

</td>

<td width="63%">

<div align="center">商品名</div>

</td>

<td width="14%">

<div align="center">主分类</div>

</td>

<td width="13%">

<div align="center">操作</div>

</td>

</tr>

<%

for i=1 to rs.PageSize

if rs.EOF or rs.BOF then '本条件判断是否到了尽头

exit for

end if

%>

<tr>

<td width="10%" align=center><%=rs("ID")%></td>

<td width="63%" align=center><%=rs("name")%></td>

<td width="14%" align=center><%=rs("category_one")%> </td>

<td width="13%">

<div align="center">

<INPUT type="button" value="Button" id=button1 name=button1

onclick="javascript:window.open('tomodify.asp?id=<%=rs("ID")%>&zfenlei=<%=rs("category_one")%>','','resizable=no,width=240,height=160')">

</div>

</td>

</tr>

<%

currentRecord=currentRecord+1 '取的当前页的记录数

rs.MoveNext

next

rs.Close

%>

</table>

<div align="center" class="bfont">合计<%=recordCount%> 条记录 | 第

<%

pageNum_record=(pageNum-1)*pageSize+1 '初始记录位置

pageNum_record_=pageNum_record+currentRecord-1 '末记录位置

Response.Write pageNum_record

%>

-<%=pageNum_record_%>条 | 第<%=pageNum%>页 |共<%=pagecuont%>页

<%

if pagecuont >0 then '防止当前返回的为空记录,即数据库中该数据集为空

if pageNum > 1 then %>

<a href="modifychart.asp?pageNum=1"> <font color="#FFFFFF">首页</font></a>

<%

else Response.Write "首页"

end if

if pageNum > 10 then

'如有需要,请在这里添上如果不足10页时该实现前n页的代码,

'请参考下面的如果后面不足10页时该怎么样处理的代码和思路

%>

<a href="modifychart.asp?pageNum=<%=(pageNum-10)%>"> <font color="#FFFFFF">前10页</font></a>

<%

end if

if (pageNum+10) < pagecuont then

'这里也相同参考下面的思路

%>

<a href="modifychart.asp?pageNum=<%=(pageNum+10)%>"> <font color="#FFFFFF">下10页</font></a>

<%

end if

if (pageNum+10) < pagecuont then

'这里判断后面是否还有10页

endpage=pageNum+9

else

endpage=pageCount

end if

for i=pageNum to endPage

%>

<a href="modifychart.asp?pageNum=<%=i%>">第<%=i%>页</a>

<%

next

if pageNum <> pageCount then

%>

<a href="modifychart.asp?pageNum=<%=pagecuont%>"> <font color="#FFFFFF">末页</font></a>

<%

end if

end if 'end of --->if pageCount >0 then

%>

</div>

</body>

</html>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航