<% Sub Head() Response.Write ""&_ "
我的日记分类
" Set rs=conn.Execute("Select * From notebookcategory order by id asc") Do While Not rs.eof Response.Write ""& rs("category") &"  " rs.MoveNext Loop Response.Write "
" End Sub Call Head() action=RequestSafeStr("action") Select Case action Case "add" Call add() Case "save" Call save() Case "edit" Call edit() Case "editsave" Call editSave() Case "del" Call del() Case "top" Call top() Case else Call show() End Select %> <% Sub save() title=RequestFormStr("title") categoryid=RequestFormNum("categoryid") content=RequestFormStr("content") password=RequestFormStr("password") If title="" Then Call MessageBox("请输入标题!","") Response.End End If If content="" Then Call MessageBox("请输入内容!","") Response.End End If set rs=Server.CreateObject("ADODB.Recordset") sql="select * from notebook" rs.open sql,conn,1,3 rs.addnew rs("title")=title rs("categoryid")=categoryid rs("content")=content rs("password")=password rs.update rs.close Call MessageBox("添加日记成功!","notebook.asp") End Sub Sub editSave() id=RequestFormNum("id") If id<>0 then title=RequestFormStr("title") categoryid=RequestFormNum("categoryid") content=RequestFormStr("content") password=RequestFormStr("password") set rs=Server.CreateObject("ADODB.Recordset") sql="select * from notebook Where id="& id &"" rs.open sql,conn,2,3 If Not rs.eof then rs("title")=title rs("categoryid")=categoryid rs("content")=content rs("password")=password rs.update End If rs.close Call MessageBox("修改日记成功!","notebook.asp") End If End Sub 'del Sub del() id=RequestQueryNum("id") If id<>0 Then conn.Execute("delete From notebook Where id="& id &"") Call MessageBox("删除成功!","notebook.asp") End If End Sub 'top Sub top() id=RequestQueryNum("id") intTop=RequestQueryNum("top") If id<>0 Then conn.Execute("Update notebook set [top]="& intTop &",toptime=Now() Where id="& id &"") If intTop=1 Then strMsg="置顶成功!" Else strMsg="取消置顶成功!" End If Call MessageBox(strMsg,"notebook.asp") End If End Sub Sub show() cid=RequestQueryNum("cid") If cid<>0 Then sql="Select * From notebook Where categoryid="& cid &" order by top desc,id desc" Else sql="Select * From notebook order by top desc,id desc" End If Set mypage=new xdownpage '创建对象 mypage.getconn=conn '得到数据库连接 mypage.getsql=sql mypage.pagesize=20 '设置每一页的记录条数据为5条 set rs=mypage.getrs() '返回Recordset %>
写日记 
<% for i=1 to mypage.pagesize If rs.eof Then Exit for End If %> <% rs.MoveNext Next %>
日记管理
编号 标题 查看 点击 发表日期 操作
<%=rs("id")%> "><%=rs("title")%> " target="_blank">查看 <%=rs("hits")%> <%=rs("posttime")%> <%If rs("top")=0 then%> &top=1">置顶 <%else%> &top=0">取消置顶 <%End If%> ">修改 )">删除
<%mypage.showpage() %>
<% End Sub Sub add() %>
写日记
标题:    *
分类:  
内容:
加密:   (不写,表示不设置密码)
 
<% End Sub Sub edit() id=RequestQueryNum("id") Set rs=conn.Execute("Select * From notebook Where id="& id &"") If Not rs.eof Then %>
修改日记
标题:   " size="25" style="width:300"> *
分类:  
内容:
加密:   " size=20 style="width:200">(不写,表示不设置密码)
 
<% End If End Sub %>