Set rs = Server.CreateObject("ADODB.Recordset") sql="select * from data order by news_id ASC" rs.open sql,conn,3,2
'查找编号 if rs.bof then reco=0 else rs.movelast reco=Clng(rs("news_id"))+1 end if
rs.addnew rs("news_id")=reco
if request.form("head")="YES" then rs("news_head")=-1 end if
rs("news_class")=class rs("news_class_name")=request.form("class_name") if request.form("pic")《》"" then rs("news_pic")=request.form("pic") rs("news_title")=request.form("title")&"(图文)" else rs("news_title")=request.form("title") end if
if request.form("head")="YES" then rs("news_head")=-1 end if
tmpmess=request.form("comment") tmpmess=replace(tmpmess,chr(10)," ") tmpmess=replace(tmpmess,"《","《") tmpmess=replace(tmpmess,"》","》") tmpmess=replace(tmpmess," "," ") rs("news_comment")=tmpmess rs("news_year")=year(Date) rs("news_month")=month(Date) rs("news_day")=day(Date) if Instr(Time,"下午")》0 then tmp=left(right(Time,8),2)+12 rs("news_time")=tmp&right(Time,6) else rs("news_time")=tmp&right(Time,8) end if
if Request.ServerVariables("REQUEST_METHOD")="POST" then
if not rs.bof then rs.movefirst end if do while not rs.eof n=trim(cstr(rs("news_id"))) if request.form(n)="OFF" then rs.delete rs.update end if rs.movenext loop response.redirect "delete.asp"
rs.close end if response.flush %》 delete.asp也是一个构成webadmin.htm的管理页面的asp文件,它负责新闻数据库的标题显示,以便让您知道现在库用有些什么新闻。同时可以通过它来删除新闻记录,那么我们在使用新闻的主页里反应出来的结果就是动态的了,新闻可以在线添加和删除。令外一个附加的asp程序 set_diap.asp是用于控制每一类新闻在主页上显示的数目的,它主要使用application对象来设定。