教你利用ASP實現(xiàn)上一篇,下一篇過程實例代碼分享
作者: 來源: 發(fā)布時間:2011-6-17 11:33:18 點擊:
這篇文章提供給大家分享的是關(guān)于利用ASP實現(xiàn)上一篇,下一篇過程實例代碼,希望能對大家有用。
Rem==上一篇==
Rem======================================================
Rem= 參數(shù)說明:
Rem= pid當(dāng)前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= 參數(shù)函意和上過程一樣
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
實現(xiàn)代碼:
偶數(shù)據(jù)庫里有表:
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")%> ' 下一篇
Rem======================================================
Rem= 參數(shù)說明:
Rem= pid當(dāng)前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= 參數(shù)函意和上過程一樣
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
實現(xiàn)代碼:
偶數(shù)據(jù)庫里有表:
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")%> ' 下一篇
[收藏此文章]