模仿PHP写的ASP分页

2016-01-29 18:51 16 1 收藏

模仿PHP写的ASP分页,模仿PHP写的ASP分页

【 tulaoshi.com - ASP 】

 

<%
' 分页程序
' total_records 总记录数
' everypage_records 每页显示条数
' current_page 当前页数
' url 要传递的url,这里可以含有要传递的变量,比如 "list.asp?" 或者"list.asp?keyword=key&"
' 程序调用比较简单,不过还是比PHP的麻烦,继续努力中

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

sub show_page(total_records,everypage_records,current_page,url)

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

 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_page1 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
%

 

来源:https://www.tulaoshi.com/n/20160129/1507541.html

延伸阅读
标签: PHP
序:  微软的ASP是一项强大的动态WEB页面技术,我已经使用了一年的ASP,用它创建了许多的WEB站点,但是现在我的公司正想转向另一项叫PHP的INTERNET技术,来进行以后的WEB站点开发。  问题是我们已经习惯于使用ASP,并且喜欢用它,为什么我们要转向PHP呢?  开放源码运动  首先,我们认识到,开源运动使我们获得了强大...
标签: ASP
  <% '仿 Lotus Notes 的界面程序 '作者:塞北的雪 '创作日期:2002年3月 '修改日期:2005年3月 '为了安全和共享的方便,将其中asp程序的标记改成中文字符,使用时可以批量替换回 % <html <head <meta http-equiv="Content-Type" content="text/html; charset=gb2312" <style .tHeader{font-weight:bold;background-colo...
标签: PHP
  下面是分页示例程序,看起来可能比较繁琐,但其实你只要用一下就会发现,"一切原来如此简单" :) example.php <?php $conn = ociplogon("test","123456","test123"); include_once "pager.inc.php"; ? <?php /** 分页测试开始 */ // {{{ 初始分页对象 $pager = new pager(); ...
标签: PHP
  <html<body<table border=1 <? $id=@mssql_connect("ddy","sa"," ") or die("连接不上"); $db=mssql_select_db("ddy",$id); $query="select * from lr00 order by lr0012 desc"; $result=mssql_query($query); if($result): if($tt==""){ $...
标签: Web开发
代码如下:     rs.open sql,conn,1,1     if rs.eof and rs.bof then      response.write "p align='center'还没找到文章/p"   else    totalPut=rs.recordcount    maxperpage=18 &nb...

经验教程

348

收藏

7
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部