上一篇,下一篇过程代码
程序员文章站
2023-11-27 14:04:58
rem==上一篇== rem================================================================ rem=&nb...
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")%> ' 下一篇
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")%> ' 下一篇