ASP进阶之文章在线管理更新--管理页面篇
作者:沙滩小子
前面讲述了关于文章管理系统的密码及密码验证,通过密码验证可以限制一般浏览者所能进入的页面,这里所要限制的就是普通用户所不能进入的页面,也就是包括管理页面、删除文章页面、修改文章页面以及修改用户信息和修改栏目信息的页面。其实这里的主管理页面就是和文章管理系统的主页面类似的页面,只是在里面添加了一些有关管理内容的连接,以方便管理者对文章进行在线的修改删除等操作。
下面就为大家介绍这一页面的主要程序内容,由于它和文章管理的主页面差不多,所以这里只是把其程序写出来,并注明和主页面不同的地方,其他相同的部分请大家参考本专题的第七节!
文件manage.asp
"打开数据库连接
1
2"限制非管理用户进入,这个在本专题的第七节有介绍
3if request.cookies("adminok")="" then
4response.redirect "login.asp"
5end if
1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4<title>ASP技巧专题</title>
5<meta content="Microsoft FrontPage 3.0" name="GENERATOR"/>
6<link href="style.css" rel="stylesheet" type="text/css"/>
7<script language="javascript">
8function popwin2(id,path)
9{ window.open("openarticle.asp?id="+id+"&ppath="+path,"","height=450,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
10}
11</script>
12</head>
const MaxPerPage=18
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
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=1
end if
set rstype=server.createobject("adodb.recordset")
typesql="select * from type where typeID="&cstr(typeid)
rstype.open typesql,conn,1,1
if not rstype.eof then
typename=rstype("type")
end if
rstype.close
set rstype=nothing
1<body>
2<div align="center"><center>
3<table border="0" cellpadding="0" cellspacing="0" width="92%">
4<tr>
5<td style="border-left: thin dotted rgb(0,128,0); border-right: thin dotted rgb(0,128,0)" width="100%"><p align="center"><br/>
6动网ASP技巧专题>><font color="#FF0000">```
7response.write ""&amp;typename&amp;""
8```</font><br/>
9<center>
10<a href="manage.asp?typeid=1">ASP教程</a>|<a href="manage.asp?typeid=2">ASP FAQ</a>|<a href="manage.asp?typeid=3">ASP文摘</a>
11|<a href="manage.asp?typeid=4">ASP实例</a>|<a href="manage.asp?typeid=5">ASP安全</a>|
12
13"显示系统管理页面相关连接,用于修改管理员密码名称以及增加修改删除栏目,这个在后面将有介绍
14<a href="changepass.asp" title="用于修改管理员密码名称以及增加修改删除栏目"><font color="red">管理页面</font></a>
15<div align="center">```
16
17sql="select * from article where typeid="+cstr(typeid)+" order by data desc"
18Set rs= Server.CreateObject("ADODB.Recordset")
19rs.open sql,conn,1,1
20if rs.eof and rs.bof then
21response.write "<p align="center"> 还 没 有 任 何 文 章</p>"
22else
23totalPut=rs.recordcount
24totalPut=rs.recordcount
25if currentpage&lt;1 then
26currentpage=1
27end if
28if (currentpage-1)*MaxPerPage&gt;totalput then
29if (totalPut mod MaxPerPage)=0 then
30currentpage= totalPut \ MaxPerPage
31else
32currentpage= totalPut \ MaxPerPage + 1
33end if
34
35end if
36if currentPage=1 then
37showpage totalput,MaxPerPage,"manage.asp"
38showContent
39showpage totalput,MaxPerPage,"manage.asp"
40else
41if (currentPage-1)*MaxPerPage<totalput (currentpage-1)*maxperpage="" <div="" ```="" align="center" bookmark="rs.bookmark" conn="nothing" conn.close="" currentpage="1" dim="" else="" end="" i="0" if="" rs="nothing" rs.close="" rs.move="" set="" showcontent="" showpage="" sub="" then="" totalput,maxperpage,"manage.asp"=""><center><table border="1" bordercolordark="#FFFFFF" bordercolorlight="#000000" cellpadding="0" cellspacing="0" width="589">
42<tr>
43<td align="center" bgcolor="#D0D0D0" height="20" width="46"><strong>ID号</strong></td>
44<td align="center" bgcolor="#D0D0D0" width="400"><strong>文章标题</strong></td>
45<td align="center" bgcolor="#D0D0D0" width="69"><strong>修改</strong></td>
46<td align="center" bgcolor="#D0D0D0" width="68"><strong>删除</strong></td>
47</tr>
do while not rs.eof
1<tr>
2<td height="23" width="46"><p align="center">```
3=rs("articleid")
4```</p></td>
5<td width="400"><p align="center"><a ```)"="" articleid")="" href="javascript:popwin2(```
6=rs(">```
7=rs("title")
8```</a></p></td>
9
10"显示与修改删除的相关连接,具体程序在后面章节将有介绍
11<td width="69"><p align="center"><a ```"="" articleid")="" href="edit.asp?id=```
12=rs(">修改</a></p></td>
13<td width="68"><p align="center"><a ```"="" articleid")="" href="delete.asp?id=```
14=rs(">删除</a></p></td>
15</tr>
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
1</table>
2</center></totalput></div>```
3
4end sub
5
6function showpage(totalnumber,maxperpage,filename)
7dim n
8if totalnumber mod maxperpage=0 then
9n= totalnumber \ maxperpage
10else
11n= totalnumber \ maxperpage+1
12end if
13response.write "<form ?typeid="&amp;typeid&amp;" action="&amp;filename&amp;" method="Post">"
14
15"显示增加文章相关连接,关于添加文章在本专题的第一、二节有介绍
16response.write "<p align="center"><a href='addarticle.asp?typeid="&amp;typeid&amp;"'><font color="red">增加文章</font></a> "
17if CurrentPage&lt;2 then
18response.write "<font color="#000080">首页 上一页</font> "
19else
20response.write "<a ?page='1&amp;typeid="&amp;typeid&amp;"' href="&amp;filename&amp;">首页</a> "
21response.write "<a &typeid="&amp;typeid&amp;" ?page="&amp;CurrentPage-1&amp;" href="&amp;filename&amp;">上一页</a> "
22end if
23if n-currentpage&lt;1 then
24response.write "<font color="#000080">下一页 尾页</font>"
25else
26response.write "<a &typeid="&amp;typeid&amp;" ?page="&amp;(CurrentPage+1)&amp;" href="&amp;filename&amp;">"
27response.write "下一页</a> <a &typeid="&amp;typeid&amp;" ?page="&amp;n&amp;" href="&amp;filename&amp;">尾页</a>"
28end if
29response.write "<font color="#000080"> 页次:</font><strong><font color="red">"&amp;CurrentPage&amp;"</font><font color="#000080">/"&amp;n&amp;"</font></strong>页 "
30response.write "<font color="#000080"> 共<b>"&amp;totalnumber&amp;"</b>篇文章 <b>"&amp;maxperpage&amp;"</b>篇文章/页</font> "
31response.write " <font color="#000080">转到:</font><input class="smallInput" maxlength="10" name="page" size="4" type="text" value="¤tpage&amp;"/>"
32response.write "<input class="buttonface" name="cndok" type="submit" value="Goto"/></p></form>"
33end function