Copy Code code as follows:
rem== on an Article = =
rem================================================================
rem= parameter Description:
rem= pid current id,prame: column prefix (such as General web_news table, when the field is generally wn_**,prame on behalf of WN)
rem= ptable (table prefix). If the general table name is: Station name _ Table (shenzhe_news) PTable: On behalf of Shenzhe)
Rem= Description: The above naming method enables the process to achieve universal
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 = "Previous: no News"
Else
Pre = "<a href=" &url& ". asp?" &id& "=" &rs (0) & ">" &rs (1) & "</a>"
End If
Getpre = Pre
End Function
Rem = Next article
rem=============
The rem= parameter is the same as the previous procedure.
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 = "Next: no News"
Else
NNext = "<a href=" &url& ". asp?" &id& "=" &rs (0) & "> Next:" &rs (1) & "</a>"
End If
GetNext = NNext
End Function
Implementation code:
I have a table in my database:
City_active city_date City_note
City_active main fields are: Ca_id,cd_title
City_date main fields are: Cd_id,cd_title
City_note main fields are: cn_id, Cn_title
This reference can be:
Quote the next article in show_note.asp?cn_id=4
<%=getpre (cn_id, "cn", "note")%> ' last article
<%=getnext (cn_id, "cn", "note")%> ' next