⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.asp

📁 一个简单的留言板!可以很好的学习学习
💻 ASP
字号:
<!--#include file="conn.asp" -->
<%
set rs=server.createobject("adodb.recordset")
 sql="select * from admin "
 rs.open sql,conn,1,1

'###检查cookies,如果密码正确侧进入管理状态
 if rs("user")="" then
else
  if session("user")=rs("user") and session("pwd")=rs("pwd") then
   adminok="ok"
  end if
end if
'###检查结束###
 %>
 
<%
   const MaxPerPage=2   '单独页最大记录数 const 用来申明常量
   dim sql 
   dim rs
   dim totalPut   '总记录
   dim CurrentPage  '当前页次
   dim TotalPages   '总页数
   dim i
%>
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from book order by id desc"
rs.open sql,conn,1,2 
%>
<html>
<head>
<title>留言板</title>
<link href="aaa.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
-->
</style>
</head>

<body>
<div align="center"><font color="#666666" size="6">我的留言板</font> <br>
  <table width="500" border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td><div align="right"><a href="write.asp">发表新主题</a></div></td>
    </tr>
    <tr>
      <td><script language="JavaScript" src="scroll.js" type="text/JavaScript"></script></td>
    </tr>
  </table>
    
  <% If rs.EOF And rs.BOF Then %>
  <table width="500" border="0" cellpadding="0" cellspacing="0" class="tableline">
    <tr> 
      <td class="tdpx"> <div align="center">暂无留言!</div></td>
    </tr>
  </table>
  <hr align="center" width="500" size="1" noshade>
  大飞猪教学ASP经典实例 
  <% Response.end %>
  <% End If %>

<!-- 分页功能代码块,可独立使用 -->
<% 
  rs.MoveFirst  '注意放到前面来,否则到任何页总是在第一个记录上
  rs.pagesize=MaxPerPage  '设置每页最多显示多少条记录
  If trim(Request("Page"))<>"" then  '如果请求的页次不为空
	CurrentPage= CLng(request("Page"))   'clng是转换成长整型数据类型,并赋值到当前页次上
	If CurrentPage> rs.PageCount then  '如果当前页次大于总页数,则将最大页次赋值到当前页次上
		CurrentPage = rs.PageCount 
	End If 
Else 
	CurrentPage= 1 '一切条件不成立,将当前页设为第一页
End If 


 totalPut=rs.recordcount '将总记录赋值于TOTALPUT
	if CurrentPage<>1 then '如果当前页数不等于第一页
		if (currentPage-1)*MaxPerPage<totalPut then  '如果当前页减一乘以每页最大的记录数小于总记录的话
			rs.move(currentPage-1)*MaxPerPage  '相对当前记录数向后移动
			dim bookmark  '定义书签变量
			bookmark=rs.bookmark '将当前记录的标签赋于变量BOOKMARK上
		end if 
	end if

	dim n,k 
	if (totalPut mod MaxPerPage)=0 then  '总记录数与每页最大记录数求余的结果为零时,则N返回整数页次,否则再加一.
		n= totalPut \ MaxPerPage
	else  
		n= totalPut \ MaxPerPage + 1  
	end if
%>
  <%
i=0
Do While Not rs.EOF and i<maxperpage
%>
  <table width="500" border="0" cellpadding="5" cellspacing="1" bgcolor="#000000">
    <tr bgcolor="#CCCCCC"> 
      <td width="71"><div align="right">姓名:</div></td>
      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr> 
            <td width="42%"><%= rs("name") %></td>
            <td width="12%"><div align="right"><a href="#" title="<%= rs("oicq") %>">QICQ</a></div></td>
            <td width="15%"><div align="right"><a href="mailto:<%= rs("email") %>" title="给<%= rs("name") %>发信">EMAIL</a></div></td>
            <td width="19%"><div align="right"><a href="http://<%= rs("homepage") %>">HOMEPAGE</a></div></td>
            <td width="12%"><div align="right"><a href="reply.asp?id=<%=rs("id")%>">回复</a></div></td>
          </tr>
        </table></td>
    </tr>
    <tr bgcolor="#E3E3E3"> 
      <td valign="top">
<div align="right">留言内容:</div></td>
      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr> 
            <td><%=server.htmlencode(rs("content"))%></td>
          </tr>
          <tr> 
            <td><div align="right"><%= rs("name") %>发表于<%= rs("time") %></div></td>
          </tr>
        </table></td>
    </tr>
    <tr bgcolor="#C8C8C8"> 
      <td><div align="right">站长回复:</div></td>
      <td width="344"><%= rs("repcontent") %></td>
      <td width="51"><div align="center"> <a href="del.asp?id=<%= cstr(rs("id")) %>">删除</a> 
        </div></td>
    </tr>
  </table>
  <hr width="500" size="1" noshade>  
  <%
i=i+1
rs.MoveNext
Loop
%>  
  <br>
  <table width="500" border="0" cellpadding="3" class="tbline">
    <tr> 
      <td width="412" valign="bottom"> 
        <!-- 分页显示代码块 可独立使用,注意和上面分页功能代码配使用 -->
        <div align="center">当前第<%=currentpage%>页 总共<%=n%>页 共<%=rs.recordcount%>个留言 
          <%k=currentPage
		if k<>1 then
			response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
			response.write "[<b>"+"<a href='index.asp?page="&cstr(k-1)&"'>上一页</a></b>] "
		else
			Response.Write "[首页] [上一页]"
		end if
		if k<>n then
			response.write "[<b>"+"<a href='index.asp?page="&cstr(k+1)&"'>下一页</a></b>] "
			response.write "[<b>"+"<a href='index.asp?page="&cstr(n)&"'>尾页</a></b>] "
		else
			Response.Write "[下一页] [尾页]"
		end if
          
	%>
        </div></td><form method=POST action=index.asp name=setPagesList>
        <td width="68" valign="middle">
<input type=text name=page size=5 maxlength=10 value="<%= currentpage %>">
        </td>
      </form>
    </tr>
  </table>
  <br>
  <hr align="center" width="500" size="1" noshade>
  大飞猪教学ASP经典实例   
  <%if adminok="ok" then%>[<a href="editadmin.asp?user=<%=user%>" target="_self"><font color="#FF0000">修改资料</font></a>][<a href="login.asp?exit=ok" target="_self"><font color="#FF0000">退出登陆</font></a>]<%else%>
  | <a href="login.asp" target="_self">版主管理</a> 
  |
<%end if%></div>
</body>
</html>
<% rs.close
set rs=nothing
conn.close
set conn=nothing %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -