Previous article, the next Process code _ Application Skills

Source: Internet
Author: User

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

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.