代码如下:
<%
function thenext
newrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from articles where id>"&a1&" order by id"
set newrs=conn.execute(sql)
if newrs.eof then
response.Write("没有了")
else
a2=newrs("id")
response.Write("下一篇")
end if
end function
%>
'定义一个thehead函数来找出下一篇的ID,如果当前记录已经是最前面的一条记录,则输出文字“没有了”
<%
function thehead
headrs=server.CreateObject("adodb.recordset")
sql="select top 1 * from articles where id<"&a1&" order by id desc"
set headrs=conn.execute(sql)
if headrs.eof then
response.Write("没有了")
else
a0=headrs("id")
response.Write("上一篇")
end if
end function
%>
'数据库连接文件
'取得传递过来的ID,显示文章标题作者和内容
<%
id=request("id")
sql="select * from articles where id="&id
set rs=conn.execute(sql)
%>
<%
boardid=rs("boardid")
%>
| 相关文章: '根据当前文章的栏目号,找出同一栏目的文章 <%sql="select * from articles where boardid="&boardid&"" set rs=conn.execute(sql)%> <%Do While Not rs.EOF %>
<% rs.MoveNext%><%Loop%> |
showpage.asp页面内容
--------------------------------------------------------------------------------------------------------
<%
'***********************************************
'函数名:PasteURL
'作 用:向地址中加入 ? 或 &
'参 数:strUrl ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function PasteURL(strUrl)
if strUrl="" then
PasteURL=""
exit function
end if
'如果传入的URL末尾不是"?",有两种情况:
'1.无“?”,此时需加入一个“?”
'2. 有“?”再判断有无“&”
if InStr(strUrl,"?")
if InStr(strUrl,"&")
else
PasteURL=strUrl
end if
else
PasteURL=strUrl & "?"
end if
else
PasteURL=strUrl
end if
end function
'***********************************************
'过程名:ShowPage
'作 用:显示“上一页 下一页”等信息
'参 数:sDesURL ----链接地址,可以是一个文件名,也可以是一个有一些参数所URL
' nTotalNumber ----总数量
' nMaxPerPage ----每页数量
' nCurrentPage ----当前页
' bShowTotal ----是否显示总数量
' bShowCombo ---是否用下拉列表显示所有页面以供跳转。有某些页面不能使用,否则会出现JS错误。
' sUnit ----计数刻度(如每页数条或每页多少个)
'***********************************************
sub ShowPage(sDesURL, nTotalNumber, nMaxPerPage, nCurrentPage, bShowTotal, bShowCombo, sUnit)
dim n, i,strTemp,strUrl
'计算页数
if nTotalNumber mod nMaxPerPage=0 then
n= nTotalNumber \ nMaxPerPage
else
n= nTotalNumber \ nMaxPerPage+1
end if
'判断nCurrentPage
if nCurrentPage < 1 then
nCurrentPage = 1
elseif nCurrentPage > n then
nCurrentPage = n
end if
Response.Write ""
end sub
%>
实例引用页面内容
--------------------------------------------------------------------------------------------------------
<%
'显示相关列表
sql2="select * from IM_P_Blog order by hits desc"
set rs2=server.createobject("adodb.recordset")
rs2.open sql2,conn,3,2
'分页部分
CurrentPage = Request("page")
if Not IsNumeric(CurrentPage) Then
CurrentPage = "1"
end if
if rs2.EOF Then
response.write("暂无相关讨论主题...
")
Response.End
end if
CurrentPage=Cint(CurrentPage)
'自定义每页显示信息数
rs2.PageSize =30
'默认信息 conMaxPerPage_Default
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > rs2.PageCount Then
CurrentPage = rs2.PageCount
end if
rs2.AbsolutePage = CurrentPage
if not rs2.eof then
i=1
do while not rs2.eof
'这里显示分面列表中的内容
'自己发挥
'/********************************************/
i=i+1
if i>rs2.PageSize then exit do
rs2.movenext
loop
end if
'调用页面函数
call showpage("bloglist.asp", rs2.RecordCount, rs2.PageSize, CurrentPage, true, true, "项")
%>
注释:以上直接套用就可以了。其中以下
'这里显示分面列表中的内容
'自己发挥
'/********************************************/
为你自己分页页面内容显示。如不懂,可以Qme334194041
WP开发21:wordpress网站文章页模板,如何调用文章的标题、内容、标签等信息?
自己写
关键字: ASP中SQL分页
发给你了.你查收一下