zoukankan      html  css  js  c++  java
  • ASP 数据库分页

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <%
    Response.buffer=false
    %>
    <!--#include file="./inc/conn.asp"-->
    <!--#include file="./inc/const.asp"-->
    <!--#include file="./inc/char.asp"-->
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>会员</title>
    <link href=./css/main.css rel=stylesheet>
    <script language=JavaScript>
    <!--
    function DoEmpty(params)
    {
    if (confirm("真的要删除这条记录吗?删除后此记录里的所有内容都将被删除并且无法恢复!"))
    window.location = params ;
    }
    //-->
    </script>
    </head>
    <body>
    
    <br />
    <table width="98%" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center">
    <tr bgcolor="#CCCCCC" align=center>
      <td colspan="5"><b>信息</b></td>
    </tr>
    <%
    dim pagecount,page,Spage,Epage,recordcount,i
    page = request.querystring("page")
    if page = "" or IsNull(page) then page = 1
    if not IsNumeric(page) then page = 1
    page = Cint(page)
    set rs = server.CreateObject ("Adodb.recordset")
    sql = "select * from goods  order by id asc"
    rs.open sql,conn,1,1
    recordcount = RS.RecordCount
    RS.PageSize = PAGESIZE
    pagecount = RS.PageCount
    if page < 1 then
        page = 1
    elseif page > pagecount then
        page = pagecount
    end if
    if RS.EOF  then%>
    <tr bgcolor="#ffffff" height=20>
      <td colspan="4" ><center><font color=#cc0000>目前还没有任何信息!</font><%if session("userkey")=4 then%> 请[<a href=add.asp?action=addmsg>点击这里</a>]发布信息<%end if%></td>
    </tr></table>
    <%else%>
    <tr bgcolor="#ffffff" height=25><td colspan="4" ></tr>
    <%if recordcount > 0 then RS.AbsolutePage = page
      for i = 1 to PAGESIZE
      if RS.EOF then exit for%>
    <tr bgcolor="#dddddd"><td width=3%><center><img src=./img/folder.gif></td><td><b><%=rs("goods_id")%></b> (<%=rs("goods_name")%>)</td><td width=10%><center><font color=blue><%=rs("goods_price")%></font></td><td width=10%> |</td></tr>
    
    <%
    RS.MoveNext()
    next
    end if
    %>
    </table>
    
    <%
    if pagecount > 0 then
        response.write("<table width=""95%"" align=center cellspacing=3 cellpadding=3><tr><td align=right>")
        response.write("页次:<font color=red><b>" & page & "</font>/" & pagecount & "</b>  每页<b>" & pagesize & "</b>  共<b>" & recordcount & "</b>条留言  分页:")
        Spage = page mod PARTSIZE
        if page > PARTSIZE then
            if Spage = 0 then Spage = PARTSIZE
            Spage = page - Spage + 1
        else
            Spage = 1
        end if
        Epage = Spage + PARTSIZE - 1
        if Epage > pagecount then Epage = pagecount
        if page > PARTSIZE then
            response.write("<a href=""?page=" & Spage - 1 & """>[<<]</a>")
        end if
        for i = Spage to Epage
            if i = page then
                response.write("[<font color=red><b>" & i & "</b></font>]")
            else
                response.write("[<a href=""?page=" & i & """>" & i & "</a>]")
            end if
        next
        if Epage < pagecount then
            response.write("<a href=""?page=" & Epage + 1 & """>[>>]</a>")
        end if
        if Spage <> 1 then response.write("[<a href=""?page=1"">首页</a>]")
        if Epage <> pagecount then response.write("[<a href=""?&page=" & pagecount & """>尾页</a>]")
        response.write("</td></tr></table><br>")    
    end if
    rs.close
    set rs=nothing%>
    
    
    
    <script type="text/javascript">
    function openwindow(url,name,iWidth,iHeight)
     {
      var url;                            //转向网页的地址;
      var name;                           //网页名称,可为空;
      var iWidth;                         //弹出窗口的宽度;
      var iHeight;                        //弹出窗口的高度;
      //window.screen.height获得屏幕的高,window.screen.width获得屏幕的宽
      var iTop = (window.screen.height-30-iHeight)/2;       //获得窗口的垂直位置;
      var iLeft = (window.screen.width-10-iWidth)/2;        //获得窗口的水平位置;
     // window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
     openWin(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
     }
     
      /**
      * 监听打开的弹窗,关闭后刷新页面
      */
     function openWin(url,text,winInfo){
     	var winObj = window.open(url,text,winInfo);
     	var loop = setInterval(function() {     
     	    if(winObj.closed) {    
     	        clearInterval(loop);    
     	        //alert('closed');    
     	        parent.location.reload(); 
     	    }    
     	}, 1);   
    }
    
    </script>
    
    <hr align="center" width="90%" size="1">
    <p align="center" class="style1">
      Powered by wgscd</p>
    </body>
    </html>
    

      

    const.asp:
    
    %>
    <%
    Const PAGESIZE=20
    Const PARTSIZE=10
    Const AboutSize=8
    %>
    
    
    conn.asp:
    
    <%
    	dim conn
    	dim connstr
    	dim db
    	db="./data/goods.mdb"
    	Set conn = Server.CreateObject("ADODB.Connection")
    	connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
    	conn.Open connstr
    	
    	
    %>
    

      

  • 相关阅读:
    swing_AbstractTableModel 创建表格
    swing_tableModel 创建表格
    LDA主题模型
    jieba分词
    LightGBM介绍及参数调优
    机器学习中常见的损失函数
    const和define区别 static
    C++四种类型转换
    行为模式->策略模式
    结构模式->享元模式
  • 原文地址:https://www.cnblogs.com/wgscd/p/11081611.html
Copyright © 2011-2022 走看看