PC6下载站

分类分类

动感首页更新实现之四 ------ 首页显示篇

关注+2004-10-07作者:蓝点


            
             
              
             
            

               
               

            



            index.asp

'读入数据库链接!


<%
'每页最大显示数为20
const MaxPERPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j

dim typename
dim keyword
keyword=trim(request("keyword"))

if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if

%>


ASP动感在线

















站 务 公 告



















查询关键字<%=keyword%>

请输入搜索字符:
name=keyword size=26>
&nbsp;&nbsp;

name=submit src="../images/search.gif" type=image>


<%
'打开数据库内容安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)*MaxPerPagers.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

%>





'循环输出数据库中的数据,一直到结束!

<%do while not rs.eof%>








<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
就是数据库要显示的内容是编写ASP的关键
'这个动作是对程序的目的,即得出显示结果!
href="<%=rs("url")%>" target="_blank"><%=rs("title")%>

(<%=rs("dateandtime")%>)
<%=rs("content")%>





<%
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 "
"
response.write "

&gt;&gt;分页&nbsp;"
if CurrentPage<2 then
response.write "首页 上一页&nbsp;"
else
response.write "首页&nbsp;"
response.write "上一页&nbsp;"
end if
if n-currentpage<1 then
response.write "下一页 尾页"
else
response.write "下一页 尾页"
end if
response.write "&nbsp;页次:"&CurrentPage&"/"&n&"页 "
response.write "&nbsp;共"&totalnumber&"篇文章 "&maxperpage&"篇文章/页 "
response.write " &nbsp;转到:"
response.write " &nbsp;&nbsp;

"

end function


%>


'版权信息!不作解释了!

ASP动感在线》编辑制作





大家注意的是两点:
1.个位可参照上面的程序举一反三!
2.<%=rs("xxx")及显示你txturl,txttitle等的内容,这是学ASP关键所在,这一点如果明白了!学ASP差不多到了一个新的境界!
展开全部

相关文章

更多+相同厂商

热门推荐

  • 最新排行
  • 最热排行
  • 评分最高
排行榜

    点击查看更多

      点击查看更多

        点击查看更多

        说两句网友评论

          我要评论...
          取消