ASP上一条记录/下一条记录实现 - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
Nov 27

ASP上一条记录/下一条记录实现 不指定

tommyhu , 20:34 , ASP , Comments(0) , Trackbacks(0) , Reads(9141) , Via Original Large | Medium | Small

下一条: select top 1 * from table where ID>NowID order by ID
上一条: select top 1 * from table where ID<NowID order by ID DESC
给出了一个函数:
'函数名:PreOrNext
'函数功能:实现上一条记录,下一条记录功能
'参数:自动编号id,显示上一条下一条的参数:opt,有两个值 ,"pre"与"next"
'注意:使用时要修改的项:BlogArticle为表名,ID为自动编号Function PreOrNext(ID, opt)

    Set rsPreOrNext = Server.CreateObject("Adodb.Recordset")
    If opt = "pre" Then sqlPreOrNext = "select * from BlogArticle where ID < " & ID & " order by id desc"
    If opt = "next" Then sqlPreOrNext = "select * from BlogArticle where  ID > " & ID & " order by id"
    rsPreOrNext.Open sqlPreOrNext, conn, 1, 1
    If rsPreOrNext.EOF Then
        PreOrNext = "首页"
    Else
        PreOrNext = "<a href=infoShow.asp?id="& rsPreOrNext("id")&" target=_blank>" & rsPreOrNext("txtTitle") & "</a>"        End If

End Function


▲返回顶部

Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot