E库技术学院--您的网络技术顾问! 网站首页素材图片库设计原稿网页模板网站赏析下载中心明星图库E库论坛  
E库技术学院
设为首页
加入收藏
我要投稿
E库首页学院首页 ┊ 图形图象 ┊ 网页设计 ┊ 网络编程 ┊ 数据库 ┊ 服务器 ┊ 建站技术 ┊ 业界新闻 ┊ 作者专栏 ┊ 常用范文 ┊ 预留栏目
  当前位置:学院首页>>网页设计教程>>网页特效教程>>模仿PHP写的ASP分页
模仿PHP写的ASP分页
[ 来源:knowsky.com | 作者: | 时间:2006-1-12 13:20:19 | 浏览:人次 ]
收藏到新浪ViVi收藏到365KEY收藏到我摘 ┊ 双击滚屏 单击停止
    <%
  ' 分页程序
  ' total_records 总记录数
  ' everypage_records 每页显示条数
  ' current_page 当前页数
  ' url 要传递的url,这里可以含有要传递的变量,比如 "list.asp?" 或者"list.asp?keyword=key&"
  ' 程序调用比较简单,不过还是比PHP的麻烦,继续努力中
  
  sub show_page(total_records,everypage_records,current_page,url)
  
   if IsNumeric (total_records) then
   total_records=Int(total_records)
   else
   total_records=0
   end if
  
   if IsNumeric (everypage_records) then
   everypage_records=Int(everypage_records)
   if everypage_records<=0 then
   everypage_records=10
   end if
   else
   everypage_records=10
   end if
  
   if IsNumeric (current_page) then
   current_page=Int(current_page)
   else
   current_page=1
   end if
  
   '取总页数,即最后一页
   if total_records mod everypage_records=0 then
   last_page=Int(total_records/everypage_records)
   else
   last_page=Int(total_records/everypage_records)+1
   end if
  
   '判断 current_page 是否符合标准,并附值给page
   if current_page>=last_page then
   page=last_page
   elseif current_page<=1 then
   page=1
   else
   page=current_page
   end if
  
   '上一页
   if page<=0 then
   prepg=0
   else
   prepg=page-1
   end if
   '下一页
   if page=last_page then
   nextpg=0
   else
   nextpg=page+1
   end if
  
   '本页开始记录
   firstcount=prepg*everypage_records
   '本页结束记录
   if nextpg>=1 then
   lastcount=(nextpg-1)*everypage_records
   else
   lastcount=total_records
   end if
   '开始分页导航条代码
   pagenav=""
   pagenav1=""
   pagenav=pagenav&"显示第<b>"&firstcount&"-"&lastcount&"</b>条记录 共<b>"&total_records&"</b> 条记录"
   pagenav1=pagenav1&"显示第<b>"&firstcount&"-"&lastcount&"</b>条记录 共<b>"&total_records&"</b> 条记录"
  
   if last_page>1 then
   '当有前后页时
   pagenav=pagenav&" <a href='"&url&"page=1'>首页</a> "
   pagenav1=pagenav1&" <a href='"&url&"page=1'>首页</a> "
   if prepg>=1 then
   pagenav=pagenav&" <a href='"&url&"page="&prepg&"'>前页</a> "
   pagenav1=pagenav1&" <a href='"&url&"page="&prepg&"'>前页</a> "
   else
   pagenav=pagenav&" 前页 "
   pagenav1=pagenav1&" 前页 "
   end if
   if nextpg>=1 then
   pagenav=pagenav&" <a href='"&url&"page="&nextpg&"'>后页</a> "
   pagenav1=pagenav1&" <a href='"&url&"page="&nextpg&"'>后页</a> "
   else
   pagenav=pagenav&" 后页 "
   pagenav1=pagenav1&" 后页 "
   end if
   pagenav=pagenav&" <a href='"&url&"page="&last_page&"'>尾页</a> "
   pagenav1=pagenav1&" <a href='"&url&"page="&last_page&"'>尾页</a> "
  
   pagenav=pagenav&"到第<input type=text name=text100 id=text100 value="&page&" size=3>页<input type=button name=button100 value=go onclick='window.location="""&url&"page=""+text100.value'>"
   pagenav=pagenav&" 共 "&last_page&" 页"
  
   pagenav1=pagenav1&"到第<input type=text name=text101 id=text101 value="&page&" size=3>页<input type=button name=button101 value=go onclick='window.location="""&url&"page=""+text101.value'>"
   pagenav1=pagenav1&" 共 "&last_page&" 页"
   end if
  
  end sub
  %>
“模仿PHP写的ASP分页”教程到此结束==>||
 相关教程
模仿PHP写的ASP分页
模仿PHP写的ASP分页
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

投稿作者:  信息来源: knowsky.com 录入时间: 2006-1-12 13:20:19
投稿信箱: web#iecool.com
设为首页 - 加入收藏 - 关于我们 - 广告服务 - 版权申明 - 友情链接 - 联系方式 - 会员投稿
E库技术学院 © 2004-2005 Edu.IEcool.Com  浙ICP备05015070号