动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP实例
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ ASP实例 ]的信息



本月文章推荐
.利用ASP将HTML格式数据传输给Exc.
.一个的无组件上传的ASP代码.
.为你的ASP程序制作一个编译组件(.
.用ASP统计用户在站点的停留时间(.
.在线实时开通WEB及FTP源程序.
.用Asp+XmlHttp实现RssReader功能.
.ASP中实现文件上传方法的研究.
.一个免费的邮件列表源程序(三).
.用SQL Server为Web浏览器提供图像.
.用ASP实现电子贺卡.
.用SQL Server为Web浏览器提供图像.
.FrontPage 2000+DB2实现数据库信.
.一个把WORD转换成HTML的程序.
.建立一个广告交换及跟踪系统.
.关于页面局部刷新例程.
.初探SSI网页制作.
.利用ASP的文件操作实现用户管理.
.一个防止外部数据提交的脚本.
.聊天室建设详解五.
.转换字符串带有http://的超级链接.

ASP进阶之文章在线管理更新(8)

发表日期:2000-8-4 |


ASP进阶之文章在线管理更新--主页面及搜索篇

作者:沙滩小子

   经过了文章的添加、保存、显示,那么现在应该来谈谈关于管理程序的显示主页面,也就是显示所有文章的标题连接,以方便浏览者查找文章,其应该具有的功能有:显示所有文章的标题连接,加入日期,浏览次数等信息,另外还必须提供分页功能,要不然这么多的文章标题在一个页面都显示出来,那将非常的费时且不便浏览,另外由于本程序在这里结合了文章分栏目搜索的功能,所以在这里也将一起介绍了。

   下面就为大家详细的介绍主页面index.asp的这些功能的实现过程以及其具体功用:

   "建立数据库连接
<!--#include file="conn.asp"-->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ASP专题栏目</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<link rel="stylesheet" type="text/css" href="style.css">
<script language="javascript">
function popwin2(path)
{ window.open(path,"","height=450,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
</script>
</head>
<%

   "定义每页最大文章标题显示量MaxPerPage,你可以自己修改这里的数字来达到你的最佳显示效果
   const MaxPerPage=18
   dim totalPut   
   dim CurrentPage
   dim TotalPages
   dim i,j

   "假如返回的页面信息是空的,也就是如果你直接输入index.asp,那么就用这里定义的页数第一页
   if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
   end if
   dim sql
   dim rs
   dim rstype
   dim typesql
   dim typeid,typename

   "如果返回的栏目信息为空,那么就用这里定义的栏目,这里指定的是第三个栏目
   if not isEmpty(request("typeid")) then
typeid=request("typeid")
   else
typeid=3
   end if

   "通过返回的栏目typeid号,打开数据库显示指定的栏目,并把其值交给typename
set rstype=server.createobject("adodb.recordset")
  typesql="select * from type where typeID="&cstr(typeid)
  rstype.open typesql,conn,1,1
  typename=rstype("type")
  rstype.close
%>

<body>
<div align="center"><center>

<table border="0" width="95%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" style="border-left: thin dotted rgb(0,128,0); border-right: thin dotted rgb(0,128,0)"><p align="center"><br>

   "显示栏目信息,当你点击了任何一个栏目,在typename的位置都会显示相关信息,这里没有采用栏目的自动显示方式是考虑了页面的显示效果,而采用手工添加的模式,要想采用自动模式,就自己写吧:)相信你学习到现在,不会连这个都编不出来吧!
    动网ASP技巧专题&gt;&gt;<font color="#FF0000"><%response.write ""&typename&""%></font><br>
    <a href="index.asp?typeid=1">ASP FAQ</a>|<a href="index.asp?typeid=2">ASP组件</a> |<a href="index.asp?typeid=3">ASP文摘</a>|<a href="index.asp?typeid=4">ASP实例</a>|<a href="index.asp?typeid=5">ASP安全</a> </p>
    <div align="center">

   "打开指定的记录集article并按照文章的加入日期排序,在这里打开有两个条件,一个是利用like来查询数据库并显示相关文章标题,还有就是通过返回的typeid显示指定栏目的文章
<%
sql="select * from article where title like '%"&request("txtitle")&"%' and typeid="+cstr(typeid)+" order by date desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1

  "如果查询数据库的结果指向记录集的开始或者结尾,表示数据库中没有任何相关文章
  if rs.eof and rs.bof then
       response.write "<p align='center'>没有或没有找到任何文章</p>"
   else
  "如果数据库内有内容,则取得数据库内文章数目
  totalPut=rs.recordcount
  "假如页面参数currentpage小于1,则指定为1
      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
  "如果分页的页数为1或者页面数减1乘与页面最大文章数小于文章总数,则用已经做好的function showpage在showContent子程序也就是显示文章标题部分的上面和下面显示分页程序
       if currentPage=1 then
            showpage totalput,MaxPerPage,"index.asp"
            showContent
            showpage totalput,MaxPerPage,"index.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then
            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
   "显示文章标题及相关数据库内容子程序  
   sub showContent
       dim i
   i=0

%>
<div align="center"><center><table border="1" cellspacing="0" width="589" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0">
      <tr>
        <td width="46" align="center" bgcolor="#D0D0D0" height="20"><strong>ID号</strong></td>
        <td width="381" align="center" bgcolor="#D0D0D0"><strong>文章标题</strong></td>
        <td width="98" align="center" bgcolor="#D0D0D0"><strong>加入日期</strong></td>
        <td width="58" align="center" bgcolor="#D0D0D0"><strong>点击</strong></td>
      </tr>
<%do while not rs.eof%>
      <tr>
   "依次显示文章ID号,文章标题,文章加入日期及浏览数,这里的openarticle.asp是用来重新定向文章的,以后将为大家介绍
        <td height="23" width="46"><p align="center"><%=rs("articleid")%></td>
        <td width="381"><p align="center"><a href="javascript:popwin2('openarticle.asp?id=<%=rs("articleid")%>&typeid=<%=cstr(typeid)%>')"><%=rs("title")%></a></td>
        <td width="98"><p align="center"><font color="red"><i><%=rs("date")%></i></font></td>
        <td width="58"><p align="center"><%=rs("hits")%></td>
      </tr>
<%
   "这里是一个循环,每显示一篇文章,则定义的变量i的值加一,当i的值大于或等于页面最大文章数时退出循环
      i=i+1
      if i>=MaxPerPage then exit do
   "显示完一篇文章以后,自动移到记录集的下一个记录
      rs.movenext
   loop
  %>
    </table>
    </center></div><%
   end sub

   "显示分页的function
function showpage(totalnumber,maxperpage,filename)
  dim n

   "利用文章数算出文章的分页数N
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  response.write "<form method=Post action="&filename&"?typeid="&typeid&">"
  response.write "<p align='center'><font color='#000080'>&gt;&gt;分页</font>&nbsp;"

   "如果当前页数小于2,则显示的文章首页和上一页不显示连接,否则用当前页数减去1来显示上一页,直接用page=1来显示首页
  if CurrentPage<2 then
    response.write "<font color='#000080'>首页 上一页</font>&nbsp;"
  else
    response.write "<a href="&filename&"?page=1&typeid="&typeid&">首页</a>&nbsp;"
    response.write "<a href="&filename&"?page="&CurrentPage-1&"&typeid="&typeid&">上一页</a>&nbsp;"
  end if

    "假如分页页数小于1,则直接显示下一页和尾页,否则用当前页数加上1来显示下一页,用已经算出的文章分页数N显示文章的尾页
  if n-currentpage<1 then
    response.write "<font color='#000080'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&typeid="&typeid&">"
    response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
  end if

    "用N和maxperpage显示文章的分页数和每页的文章数
   response.write "<font color='#000080'>&nbsp;页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
    response.write "<font color='#000080'>&nbsp;共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font> "

    "直接输入文章所在页面转到相关页面
   response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value="&currentpage&">"
   response.write "<input class=buttonface type='submit'  value=' Goto '  name='cndok'></span></p></form>"     
end function
%>

   "文章搜索相关程序
<form name="searchtitle" method="POST" action="index.asp">

   "把输入的查询字符赋值给txtitle,这样在前面的显示文章语句就起了作用title like '%"&request("txtitle")&"%'
      <p>标题:<input class="smallInput" type="text" name="txtitle" size="13"> <select class="smallSel" name="typeid" size="1">
<%

   "显示与文章相关的栏目信息,可以选择一个进行查询,这里的typeid也赋值给了typeid,以使前面的显示文章的程序对需要显示内容做出判断
  typesql="select * from type"
rstype.open typesql,conn,1,1
  do while not rstype.eof
                                sel="selected"    
             response.write "<option " & sel & " value='"+CStr(rstype("typeID"))+"' name=typeid>"+rstype("type")+"</option>"+chr(13)+chr(10)
             rstype.movenext
               loop
rstype.close
set conn=nothing
%>      </select><input class="buttonface" type="submit" value="查 询" name="title"></p>
    </form>
    </div></td>
  </tr>
</table>
</center></div>
</body>
</html>

   在这里顺便介绍一下关于打开文章的程序openarticle.asp,这个也是一个更新数据库内容(update浏览数)和重定向文件。很简单,所以这里只是简单介绍一下它的程序内容:
   
<%@ LANGUAGE="VBSCRIPT" %>
   "打开数据库连接
<!--#include file="conn.asp"-->
<%response.buffer=false
dim sql
dim rs
dim articleid
    "利用update从文章连接处返回的文章号ID更新指定文章的浏览数,以及利用response.redirect重定向文章的连接
articleid=request("id")
set rs=server.createobject("adodb.recordset")
sql="update article set hits=hits+1 where articleID="&articleid
rs.open sql,conn,1,1   
rs.close
conn.close
response.redirect "list.asp?id="&articleid
%>

   好了,关于文章的显示首页面就完成了,它可以显示文章的标题,加入日期等文章相关信息,另外还结合了文章的分栏目搜索查询功能。在这里你会发现,利用ASP对数据库进行查询并不是一件很难的事情,只要利用一个like就可以轻易实现,文章管理的前台程序我们已经基本完成,下面该来介绍管理系统的后台程序了。
上一篇:ASP进阶之文章在线管理更新(7) 人气:11414
下一篇:ASP进阶之文章在线管理更新(9) 人气:12253
浏览全部文章在线管理更新的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-7-25 WikyBlog v1.7.0.1 多国语言版
2008-7-25 乐彼网上开店系统(56770 Eshop)
2008-7-25 赛特网站管理系统sitecms v3.6.0
2008-7-25 Modoer多功能点评系统 v1.0.1 Bu
2008-7-25 Shangducms Teamsuit! v1.1.0 开
2008-7-25 幻影动漫网视频系统(Ppdong) v1.
2008-7-25 acteecompany企业网站建设系统 v
2008-7-25 恒浪整合管理系统 ims v4.1 ACCE
2008-7-25 艺术图库系统 v1.0 beta
2008-7-19 UltraEdit 简体中文增强版 14.10
2008-7-19 CentOS 5.2 i386 LiveCD
2008-7-19 Snapture多功能相机 v1.4
2008-7-19 iAcces中文输入法 v1.0Build016
2008-7-19 Cookbook烹饪秘籍 v2.5
2008-7-19 苹果专用DVD转换工具 v1.1.59汉化
2008-7-19 Modem修复软件ZiPhone修改版04.0
2008-7-19 AgileMessenger即时通讯工具美化
2008-7-19 Sketches画图软件 v0.7b6破解版


  发表评论
姓 名: 验证码:
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号