上一篇,下一篇过程代码

所属分类: 网络编程 / ASP编程 阅读数: 1675
收藏 0 赞 0 分享

复制代码 代码如下:

Rem==上一篇== 
Rem================================================================ 
Rem= 参数说明: 
Rem= pid当前ID,prame:栏目前辍(如一般web_news表,字段时一般为wn_**,prame就代表wn) 
Rem= ptable(表前辍.如一般表名是:站点名_表名(shenzhe_news) ptable:就代表shenzhe) 
Rem= 说明:采用上面命名法,可使该过程达到通用 
Rem============================================================= 

Function GetPre(pid,prame,ptable) 
    id = prame&"_id" 
title = prame&"_title" 
table = "city_"&ptable 
url = "show_"&ptable 
sql = "Select TOP 1 "&id&","&title&" FROM "&table&" Where "&id&"<"&pid&" orDER BY "&id&" DESC" 
set rs = Conn.Execute(sql) 
If rs.eof or rs.bof Then 
     pre = "上一篇:没有新闻了" 
Else 
     pre = "<a href="&url&".asp?"&id&"="&rs(0)&">"&rs(1)&"</a>" 
End If 
GetPre = pre 
End Function 

Rem = 下一篇 
Rem============= 
Rem= 参数函意和上过程一样 
Rem========== 
Function GetNext(nid,nrame,ntable) 
    id = nrame&"_id" 
title = nrame&"_title" 
table = "city_"&ntable 
url = "show_"&ntable 
sql = "Select TOP 1 "&id&","&title&" FROM "&table&" Where "&id&">"&nid&" orDER BY "&id&" " 
set rs = Conn.Execute(sql) 
If rs.eof or rs.bof Then 
     nnext = "下一篇:没有新闻了" 
Else 
     nnext = "<a href="&url&".asp?"&id&"="&rs(0)&">下一篇:"&rs(1)&"</a>" 
End If 
GetNext = nnext 
End Function 

实现代码: 
偶数据库里有表: 
city_active  city_date  city_note 
city_active主要字段有: ca_id,cd_title 
city_date主要字段有: cd_id,cd_title 
city_note主要字段有: cn_id, cn_title 

这样引用就可: 
在show_note.asp?cn_id=4里引用上一篇下一篇 
<%=GetPre(cn_id,"cn","note")%> ' 上一篇 
<%=GetNext(cn_id,"cn","note")%> ' 下一篇 

更多精彩内容其他人还在看

asp中去除内容HTML标签的三个function函数

asp中去除内容HTML标签的三个function函数
收藏 0 赞 0 分享

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解

chr(9)、chr(10)、chr(13)、chr(32)、chr(34)讲解
收藏 0 赞 0 分享

方便的大家admin及admin888 经过 md5加密后16位和32位代码

方便的大家admin及admin888 经过 md5加密后16位和32位代码
收藏 0 赞 0 分享

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集

可用的ASP无重复数字随机函数, 数组实现, 并应用于随机显示记录集
收藏 0 赞 0 分享

asp动态级联菜单代码

asp动态级联菜单代码
收藏 0 赞 0 分享

ASP中经常使用的SQL语句与教程说明

ASP中经常使用的SQL语句与教程说明
收藏 0 赞 0 分享

实例分析之用ASP编程实现网络内容快速查找的代码

实例分析之用ASP编程实现网络内容快速查找的代码
收藏 0 赞 0 分享

服务端 VBScript 与 JScript 几个相同特性的写法与示例

服务端 VBScript 与 JScript 几个相同特性的写法与示例
收藏 0 赞 0 分享

ASP 环境下 VBS 事件应用 示例代码

ASP 环境下 VBS 事件应用 示例代码
收藏 0 赞 0 分享

asp 之上传漏洞终结篇

asp 之上传漏洞终结篇
收藏 0 赞 0 分享
查看更多