Copy codeCode: Rem = previous article =
Rem ============================================== ======================================
Rem = parameter description:
Rem = pid current ID, prame: The cursor before the topic (for example, in the general web_news table, the field is generally wn _ **, and prame indicates wn)
Rem = ptable (the table name is site name_table name (shenzhe_news) ptable: shenzhe)
Rem = Note: The above naming method can make the process 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 Article: No news"
Else
Pre = "<a href =" & url & ". asp? "& Id &" = "& rs (0) &"> "& rs (1) &" </a>"
End If
GetPre = pre
End Function
Rem = next
Rem ================
Rem = the parameter function is the same as the previous process.
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 article: No news"
Else
Nnext = "<a href =" & url & ". asp? "& Id &" = "& rs (0) &"> next article: "& rs (1) &" </a>"
End If
GetNext = nnext
End Function
Implementation Code:
Even tables in the database:
City_active city_date city_note
The main fields of city_active are ca_id and cd_title.
The main fields of city_date are cd_id and cd_title.
City_note has the following fields: cn_id and cn_title.
You can reference it as follows:
In show_note.asp? Reference the previous article in cn_id = 4
<% = GetPre (cn_id, "cn", "note") %> 'previous
<% = GetNext (cn_id, "cn", "note") %> 'Next