站内搜索
广告
我写的通用分页源代码,简单到你只需要写一条 sql 语句就可以了,超级 cool!
作者:    来源:    点击:    日期:2007-4-14 23:40:02   
这个分页代码使用很简单,只有4个步骤:
(1)构造 SQL 查询语句、设置数据库连接字符串、设置每页记录显示数目
(2)插入分页控制代码 <b>navigator_init.inc</b> 文件
(3)在页面的适当地方(即你想显示“上页、下页”的地方),插入分页导航代码 <b>navigator.inc</b>
(4)用循环显示本页记录



<一> 需要分页的 ASP 文件

sample.asp

<%
    ' 取得当前 ASP 页面的完整路径,重要技巧
    theScript    = Request.ServerVariables("SCRIPT_NAME")

    ' (1)构造 SQL 语句

    myconnstr    = "driver={SQL Server};server=yourserver;uid=sa;pwd=;database=yourdatabase"
    thePageSize    = 20    ' 每页显示的记录数

    uSQL        = "select * from yourtablename "

    ' (2)插入分页控制代码
%>
<!--#include file="../inc/control/navigator_init.inc"-->

<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../default.css" type="text/css">
</head>

                      <!-- 你的 HTML 代码//-->

                      <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td>
<!--(3)插入分页导航代码-->
<!--#include file="../inc/control/navigator.inc"-->
                          </td>
                        </tr>
                      </table>
首页 上一页 [1] [2] [3] [4]  下一页 尾页 
我写的通用分页源代码,简单到你只需要写一条 sql 语句就可以了,超级 cool! 评论