Previous, next Process Code

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.