複製代碼代碼如下:
Rem==上一篇==
Rem================================================================
Rem=參數說明:
Rem=pid當前ID,prame:欄目前輟(如一般web_news表,字段時一般為wn_**,prame就代表wn)
Rem=ptable(表前輟.如一般表名是:站點名_表名(shenzhe_news)ptable:就代表shenzhe)
Rem=說明:採用上面命名法,可使該過程達到通用
Rem=============================================================
FunctionGetPre(pid,prame,ptable)
id=prame&"_id"
title=prame&"_title"
table="city_"&ptable
url="show_"&ptable
sql="SelectTOP1"&id&","&title&"FROM"&table&"Where"&id&"<"&pid&"orDERBY"&id&"DESC"
setrs=Conn.Execute(sql)
Ifrs.eoforrs.bofThen
pre="上一篇:沒有新聞了"
Else
pre="<ahref="&url&".asp?"&id&"="&rs(0)&">"&rs(1)&"</a>"
EndIf
GetPre=pre
EndFunction
Rem=下一篇
Rem=============
Rem=參數函意和上過程一樣
Rem==========
FunctionGetNext(nid,nrame,ntable)
id=nrame&"_id"
title=nrame&"_title"
table="city_"&ntable
url="show_"&ntable
sql="SelectTOP1"&id&","&title&"FROM"&table&"Where"&id&">"&nid&"orDERBY"&id&""
setrs=Conn.Execute(sql)
Ifrs.eoforrs.bofThen
nnext="下一篇:沒有新聞了"
Else
nnext="<ahref="&url&".asp?"&id&"="&rs(0)&">下一篇:"&rs(1)&"</a>"
EndIf
GetNext=nnext
EndFunction
實現代碼:
偶數據庫裡有表:
city_activecity_datecity_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")%>'下一篇