| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1003 人关注过本帖
标题:关于分页的问题。。。
只看楼主 加入收藏
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
 问题点数:0 回复次数:6 
关于分页的问题。。。

各位大虾,帮忙看一下这个程序,小弟对他写的分页实在是看不懂,还望各位给做一下批注。

谢谢了。。。。

<% if session("admin_name")="" then response.end %> <!--#include file="conn.asp"--> <% dim rs,sql dim page,maxPerPage maxPerPage=10 '每页显示的记录数 myKeyword=Request("myKeyword") page=Request("page") if (page="" or isempty(page)) then page=1 thisUrl="usermanage.asp?myKeyword="&myKeyword session("adminOldUrl")=thisUrl&"&page="&page set rs=server.createobject("adodb.recordset") sql="select * from member where 1=1" if not (myKeyword="" or isempty(myKeyword) ) then sql=sql&" and user_name like '%"&myKeyword&"%'" end if sql=sql&" order by user_id" 'response.write sql 'response.End rs.open sql,conn,1,1 rs.pagesize=MaxPerPage %> <html> <head> <title>会员管理</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link href=css.css rel=STYLESHEET type=text/css> <script language=Javascript> <!-- function jumpTo(i){ if(i==1){ this.document.location="<%=thisUrl%>";} if(i==2){ this.document.location="<%=thisUrl%>&page=<%=page-1%>";} if(i==3){ this.document.location="<%=thisUrl%>&page=<%=page+1%>";} if(i==4){ this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";} } //--> </script> </head>

<body bgcolor="#9CC7EF" text="#000000" leftmargin="0" topmargin="0"> <div align="center"><br> 会员管理 </div> <div align="center"> <table width="98%" border="1" bordercolordark=#E4E4E4 bordercolorlight=#B0B0B0 cellspacing="0" cellpadding="4"> <tr> <form method="post" action="usermanage.asp" name="form1"> <td colspan="6" bgcolor="#808080"> <div align="right"><font color="#FFFFFF">关键词</font> <input type="text" name="myKeyword" size="16" value="<%=myKeyword%>"> <input type="submit" name="Submit" value="搜索"> </div> </td> </form> </tr> <tr bgcolor="#5EA5E6"> <td width="12%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF"> 会员帐号</font></div> </td> <td width="10%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">常用电话</font></div> </td> <td width="22%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">E-mail</font></div> </td> <td width="31%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">收货地址</font></div> </td> <td width="10%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">邮政编码</font></div> </td> <td width="15%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">详细信息</font></div> </td> </tr> <% dim rsID i=1 if not (rs.eof or err) then rs.move (page-1)*maxPerPage do while not (rs.eof or err) user_yes=rs("user_yes") user_regtime=rs("user_regtime") rsID=rs("user_id") user_company=rs("user_company") comdate=datediff("d",user_regtime,date()) %> <tr title="点击查看具体信息" style="cursor:hand" onClick="Javascript:window.location='memberMod.asp?id=<%=rs("user_id")%>'"> <td width="12%"><%=rs("user_name")%>&nbsp;</td> <td width="10%"><%=rs("user_tel")%>&nbsp;</td> <td width="22%"><%=rs("user_mail")%>&nbsp;</td> <td width="31%"><%=rs("user_adds")%>&nbsp;</td> <td width="10%"><%=rs("user_postcode")%>&nbsp;</td> <td width="15%"> <a title="查看具体信息" onClick="Javascript:window.location='memberMod.asp?id=<%=rs("user_id")%>'">查看详细信息</a></td> </tr> <% i=i+1 if i>maxPerPage then exit do rs.moveNext loop %> <tr bgcolor="#4296E7"> <td colspan="6" bgcolor="#808080"> <div align="right"><font color=#FFFFFF><%=rs.recordCount%> 项 第<%=page%>/<%=rs.pageCount%> 页 </font> <%if page>1 then%> <input type="button" name="Submit3" value="首页" onClick="Javascript:jumpTo(1)"> <input type="submit" name="Submit4" value="上页" onClick="Javascript:jumpTo(2)"> <%else%> <input type="button" name="Submit3" value="首页" disabled> <input type="submit" name="Submit4" value="上页" disabled> <%end if if rs.recordCount>page*maxPerPage then%> <input type="submit" name="Submit5" value="下页" onClick="Javascript:jumpTo(3)"> <input type="submit" name="Submit6" value="末页" onClick="Javascript:jumpTo(4)"> <%else%> <input type="submit" name="Submit5" value="下页" disabled> <input type="submit" name="Submit6" value="末页" disabled> <%end if%> </div> </td> </tr> </table> </div> </body> </html>

搜索更多相关主题的帖子: page myKeyword session 
2004-06-30 17:44
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
以下是引用孤星在2004-06-30 17:44:01的发言:

各位大虾,帮忙看一下这个程序,小弟对他写的分页实在是看不懂,还望各位给做一下批注。

谢谢了。。。。

<% if session("admin_name")="" then response.end '停止输出 %> <!--#include file="conn.asp"--> <% dim rs,sql dim page,maxPerPage maxPerPage=10 '每页显示的记录数 myKeyword=Request("myKeyword") page=Request("page") if (page="" or isempty(page)) then page=1'如果page为空的话 thisUrl="usermanage.asp?myKeyword="&myKeyword session("adminOldUrl")=thisUrl&"&page="&page set rs=server.createobject("adodb.recordset") sql="select * from member where 1=1" if not (myKeyword="" or isempty(myKeyword) ) then '如果mykeyword不为空 sql=sql&" and user_name like '%"&myKeyword&"%'" end if sql=sql&" order by user_id" 'sql+order by user_id 'response.write sql 'response.End rs.open sql,conn,1,1 rs.pagesize=MaxPerPage 定义最大一页能显示的记录条数 %> <html> <head> <title>会员管理</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <link href=css.css rel=STYLESHEET type=text/css> <script language=Javascript> <!-- function jumpTo(i){ if(i==1){ this.document.location="<%=thisUrl%>";} if(i==2){ this.document.location="<%=thisUrl%>&page=<%=page-1%>";} if(i==3){ this.document.location="<%=thisUrl%>&page=<%=page+1%>";} if(i==4){ this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";} } //--> </script> </head>

<body bgcolor="#9CC7EF" text="#000000" leftmargin="0" topmargin="0"> <div align="center"><br> 会员管理 </div> <div align="center"> <table width="98%" border="1" bordercolordark=#E4E4E4 bordercolorlight=#B0B0B0 cellspacing="0" cellpadding="4"> <tr> <form method="post" action="usermanage.asp" name="form1"> <td colspan="6" bgcolor="#808080"> <div align="right"><font color="#FFFFFF">关键词</font> <input type="text" name="myKeyword" size="16" value="<%=myKeyword%>"> <input type="submit" name="Submit" value="搜索"> </div> </td> </form> </tr> <tr bgcolor="#5EA5E6"> <td width="12%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF"> 会员帐号</font></div> </td> <td width="10%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">常用电话</font></div> </td> <td width="22%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">E-mail</font></div> </td> <td width="31%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">收货地址</font></div> </td> <td width="10%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">邮政编码</font></div> </td> <td width="15%" nowrap bgcolor="#B0B0B0"> <div align="center"><font color="#FFFFFF">详细信息</font></div> </td> </tr> <% dim rsID i=1 if not (rs.eof or err) then rs.move (page-1)*maxPerPage do while not (rs.eof or err) 'rs不到最后的话 user_yes=rs("user_yes") user_regtime=rs("user_regtime") rsID=rs("user_id") user_company=rs("user_company") comdate=datediff("d",user_regtime,date()) %> <tr title="点击查看具体信息" style="cursor:hand" onClick="Javascript:window.location='memberMod.asp?id=<%=rs("user_id")%>'"> <td width="12%"><%=rs("user_name")%>&nbsp;</td> <td width="10%"><%=rs("user_tel")%>&nbsp;</td> <td width="22%"><%=rs("user_mail")%>&nbsp;</td> <td width="31%"><%=rs("user_adds")%>&nbsp;</td> <td width="10%"><%=rs("user_postcode")%>&nbsp;</td> <td width="15%"> <a title="查看具体信息" onClick="Javascript:window.location='memberMod.asp?id=<%=rs("user_id")%>'">查看详细信息</a></td> </tr> <% i=i+1 if i>maxPerPage then exit do rs.moveNext loop %> <tr bgcolor="#4296E7"> <td colspan="6" bgcolor="#808080"> <div align="right"><font color=#FFFFFF><%=rs.recordCount%> 项 第<%=page%>/<%=rs.pageCount%> 页 </font> <%if page>1 then%> <input type="button" name="Submit3" value="首页" onClick="Javascript:jumpTo(1)"> <input type="submit" name="Submit4" value="上页" onClick="Javascript:jumpTo(2)"> <%else%> <input type="button" name="Submit3" value="首页" disabled> <input type="submit" name="Submit4" value="上页" disabled> <%end if if rs.recordCount>page*maxPerPage then%> <input type="submit" name="Submit5" value="下页" onClick="Javascript:jumpTo(3)"> <input type="submit" name="Submit6" value="末页" onClick="Javascript:jumpTo(4)"> <%else%> <input type="submit" name="Submit5" value="下页" disabled> <input type="submit" name="Submit6" value="末页" disabled> <%end if%> </div> </td> </tr> </table> </div> </body> </html>


59ita点com(我就爱TA)
2004-06-30 17:56
好学
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:622
专家分:318
注 册:2004-5-4
收藏
得分:0 
涉及到很多知识,如果ASP还没入门的话建议先学好基本的,这个例子是其他应用程序的一个文件,孤立起来也不好分析
2004-06-30 17:59
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 
你看一下这个版的分页!

59ita点com(我就爱TA)
2004-06-30 18:01
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
得分:0 
哦,是啊。里面涉及到了CSS,JAVASCRIPT,ADODB。。。我刚开始学ASP所以这些东西融合到一起,看起来有点困难。不过还是谢谢各位。
2004-07-01 10:51
孤星
Rank: 1
等 级:新手上路
帖 子:127
专家分:0
注 册:2004-6-30
收藏
得分:0 

<!-- function jumpTo(i){ if(i==1){ this.document.location="<%=thisUrl%>";} if(i==2){ this.document.location="<%=thisUrl%>&page=<%=page-1%>";} if(i==3){ this.document.location="<%=thisUrl%>&page=<%=page+1%>";} if(i==4){ this.document.location="<%=thisUrl%>&page=<%=rs.pageCount%>";} } //-->

小弟对JSCRIPT基本不会,它这段代码是啥意思啊???实现的什么功能啊?

2004-07-01 11:29
belin2000
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:975
专家分:194
注 册:2004-6-2
收藏
得分:0 

实现的事页面的跳转,thisurl是一个变量,代替了真正的url。


59ita点com(我就爱TA)
2004-07-01 16:55
快速回复:关于分页的问题。。。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016532 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved