|
<%
'打开数据库内容安ARTICLEID的倒数排列!
'title like '%"&keyword&"%' 为对搜索字的查找,空者表示全部!
sql="select * from learning where title like '%"&keyword&"%' order by articleid desc"
dim sql,rs
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
'判断数据库是否为空!如果为空显示'还 没 有 任 何 文 章'
if rs.eof and rs.bof then
response.write " 还 没 有 任 何 文 章 "
else
'下面是对文章数,每页显示数的判断!大家可作其它程序的参考!!
totalPut=rs.recordcount
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
else
if (currentPage-1)*MaxPerPage
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
else
currentPage=1
showpage totalput,MaxPerPage,"index.asp"
showContent
showpage totalput,MaxPerPage,"index.asp"
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
%>
<%
end sub
'大家看到的上页下页就是从这里得到的.可作其它程序的参考!
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write " "
end function
%> |