guestbook.asp
来自「网站的后台管理代码......内容比较全面....新手比较适合」· ASP 代码 · 共 190 行
ASP
190 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../inc/adconn.asp"-->
<!--#include file="../css.asp"-->
<% set rs=server.CreateObject("adodb.recordset") %>
<%
if session("admin_name")="" then
response.end
end if%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言管理</title>
<link href="../images/default.css" rel="stylesheet" type="text/css">
</head>
<script language="javascript">
var lsdz = "";
function checkIn()
{if(confirm("你真的要删除这条留言?"))
return true
else
return false;
}
</script>
<%
'从这开始读数据
strSQL="Select * From guestbook Order By id Desc"
rs.open strSQL,conn,1,1
'分页显示初始化
page=request("page")
if page="" then
page=1
else
page=Cint(page)
end if
Section=request("section")
if Section="" then
Section=1
else
Section=Cint(Section)
end if
'变量赋值
intPageSize=15 '每页显示记录数
intSectionSize=5 '多少页为一段,像GOOGLE一样
PrevSectionText="<FONT face=webdings>7</FONT>" '上一段的链接文字
NextSectionText="<FONT face=webdings>8</FONT>" '下一段的链接文字
PrevPageText="<FONT face=webdings>3</FONT>" '上页的链接文字
NextPageText="<FONT face=webdings>4</FONT>" '下页的链接文字
strPageUrl="?t="
rs.pagesize=intPageSize
intCount=rs.RecordCount
intPageCount=rs.pagecount
intSectionCount=(intPageCount - 1) \ intSectionSize + 1
rs.AbsolutePage=page
%>
<body leftmargin="0" topmargin="0" BodyBegin>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tableBorder">
<tr>
<td width="100%" height="37" background="../images/pics/tile_sub.gif" class="tdtitle">留言板管理</td>
</tr>
<%
'循环输出
for i=1 to intPageSize
if rs.eof then exit for
if i mod 2=0 then
strclass="trclass1"
else
strclass="trclass2"
end if
%>
<tr align="center" class=<%=strclass%>>
<td><table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr align="center">
<td colspan="2"> <hr size="1" class="hr"></td>
</tr>
<tr>
<td align="right"> </td>
<td></td>
</tr>
<tr>
<td width="16%" align="right"><strong>姓 名:</strong></td>
<td width="84%"><%=trim(rs("g_Name"))%></td>
</tr>
<tr id="g_dw">
<td align="right"><strong>单 位:</strong></td>
<td><%=trim(rs("g_dw"))%></td>
</tr>
<tr id="g_email">
<td align="right"><strong>电子邮件:</strong></td>
<td><%=trim(rs("g_email"))%></td>
</tr>
<tr id="g_adrr">
<td align="right"><strong>地 址:</strong></td>
<td><%=trim(rs("g_addr"))%></td>
</tr>
<tr id="g_tel">
<td align="right"><strong>电 话:</strong></td>
<td><%=trim(rs("g_tel"))%></td>
</tr>
<tr id="g_ip">
<td height="25" align="right"><strong>IP地址:</strong></td>
<td><%=trim(rs("g_ip"))%></td>
</tr>
<tr>
<td align="right"><strong>留言时间:</strong></td>
<td><%=year(rs("g_time")) & "年" & month(rs("g_time")) & "月" & day(rs("g_time")) & "日 " & hour(rs("g_time")) & "时" & minute(rs("g_time")) & "分"%></td>
</tr>
<tr>
<td align="right"><strong>留 言:</strong></td>
<td><%=trim(rs("g_msg"))%></td>
</tr>
<tr>
<td align="right"><strong>回复内容:</strong></td>
<td>
<%
if trim(rs("g_hfmsg"))<>"" then
response.Write(trim(rs("g_hfmsg")))
else
response.Write("[未回复]")
end if
%>
</td>
</tr>
<tr>
<td height="40" colspan="2" align="center"> [<a href="javascript:;" onClick="window.open ('hfmsg.asp?id=<%=trim(rs("id"))%>','','width=600,height=500,resizable=yes,scrollbars=yes')">回复留言</a>][<a href="delemsg.asp?id=<%=rs("ID")%>" target="BackFrame" onClick="return checkIn();">删除留言</a>]</td>
</tr>
<tr align="center">
<td colspan="2"> <hr size="1" class="hr"></td>
</tr>
</table> </td>
</tr>
<%
rs.movenext
next
%>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" background="../images/pics/tile_sub.gif" class="tdtitle"> 共有<%=intCount%>记录,分<%=intPageCount%>页,当前页<%=Page%>,每页显示<%=intPageSize%>条记录
<%
'计算每一段的开始页
intStarPage=(Section-2) * intSectionSize + 1
'前一段
if Section<=1 then
response.Write(PrevSectionText & " ")
else
response.Write("<a href='" & strPageUrl & "&page=" & intStarPage & "§ion=" & Section-1 & "'>" & PrevSectionText & "</a> ")
end if
'显示页码列表
response.Write("第")
intStarPage=(Section-1) * intSectionSize + 1
for p=intStarPage to intStarPage + intSectionSize - 1
if p > intPageCount then exit for
if p=page then
response.Write("<strong>[" & p & "]</strong> ")
else
response.Write("<a href='" & strPageUrl & "&page=" & p & "§ion=" & Section & "'>[" & p & "]</a> ")
end if
next
response.Write("页")
'后一段
intStarPage=(Section) * intSectionSize + 1
if Section>=intSectionCount then
response.Write(" " & NextSectionText)
else
response.Write(" <a href='" & strPageUrl & "&page=" & intStarPage & "§ion=" & Section+1 & "'>" & NextSectionText & "</a> ")
end if
%> <select name="page" size="1" onChange="window.location='<%=strPageUrl & "§ion="%>' + (Math.floor((parseInt(this.value)-1)/<%=intSectionSize%>)+1) + '<%="&page="%>' + this.value">
<option value="<%=page%>" selected>第<%=page%>页</option>
<%
for i=1 to rs.pagecount
%>
<option value="<%=i%>" >第<%=i%>页</option>
<%
next
%>
</select> </td>
</tr>
</table></td>
</tr>
</table>
<iframe name="BackFrame" width="0" height="0" src="about:blank"></iframe>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?