熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP實現上一篇,下一篇過程代碼

2013-11-13 10:44:58  來源: .NET編程 

  


Rem==上一篇==
Rem======================================================
Rem= 參數說明:
Rem= pid當前IDprame:欄目前辍(如一般web_news表字段時一般為wn_**prame就代表wn)
Rem= ptable(表前辍如一般表名是:站點名_表名(shenzhe_news) ptable:就代表shenzhe)
Rem= 說明:采用上面命名法可使該過程達到通用
Rem=====================================================
Function GetPre(pidprameptable)
id = prame&"_id"
title = prame&"_title"
table = "city_"&ptable
url = "show_"&ptable
sql = "SELECT TOP "&id&""&title&" FROM "&table&" WHERE "&id&"<"&pid&" ORDER BY "&id&" DESC"
set rs = ConnExecute(sql)
If rseof or rsbof Then
pre = "上一篇:沒有新聞了"
Else
pre = "<a href="&url&"asp?"&id&"="&rs()&">"&rs()&"</a>"
End If
GetPre = pre
End Function

Rem = 下一篇
Rem=============
Rem= 參數函意和上過程一樣
Rem==========
Function GetNext(nidnramentable)
id = nrame&"_id"
title = nrame&"_title"
table = "city_"&ntable
url = "show_"&ntable
sql = "SELECT TOP "&id&""&title&" FROM "&table&" WHERE "&id&">"&nid&" ORDER BY "&id&" "
set rs = ConnExecute(sql)
If rseof or rsbof Then
nnext = "下一篇:沒有新聞了"
Else
nnext = "<a href="&url&"asp?"&id&"="&rs()&">下一篇:"& rs()&"</a>"
End If
GetNext = nnext
End Function

實現代碼:
偶數據庫裡有表:
city_active city_date city_note
city_active主要字段有: ca_idcd_title
city_date主要字段有: cd_idcd_title
city_note主要字段有: cn_id cn_title

這樣引用就可:
在show_noteasp?cn_id=裡引用上一篇下一篇
<%=GetPre(cn_id"cn""note")%> 上一篇
<%=GetNext(cn_id"cn""note")%> 下一篇
 


From:http://tw.wingwit.com/Article/program/net/201311/14431.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.