有asp经验的请看看(一个简单留言本的问题)(40分)

F

fly555

Unregistered / Unconfirmed
GUEST, unregistred user!
你好!
请你帮我解释一下sub showContent 与sub showpages 的实现原理
多谢了!请说祥细些
分不够再加。

<%
set conn = server.CreateObject("adodb.connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE= " &amp;
server.MapPath("ywasp.mdb")
%>
<%
dim maxpages
dim sql
dim totalrecord
dim thepage
dim TotalPages
if not isempty(request("page")) then
thepage=cint(request("page"))
else
thepage=1
end if
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from 1 order by id DESC"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
Response.Write "<br><p aligh=center align=center><font color=#ff0000 size=2>现在还没有任何记录!<br><br><a href=add.htm>我要添加</a></font></p>"
Response.End
else
%>
<%
Response.Write "<html><head><title></title>"
Response.Write "<meta http-equiv='Content-Type' content='text/html;
charset=gb2312'>"
Response.Write "<link rel='stylesheet' href='inc/3.css' type='text/css'>"
Response.Write "</head>"
%>
<body bgcolor="#FFFFFF">
<div align="center">
<table width="400" border="0" bgcolor="#A6DBFF">
<tr>
<td>
<div align="center"><b>查看留言</b>  <a href="add.htm">我要留言</a>  <a href="http://ywasp.6to23.com">版主主页</a>  <a href="admin/login.htm">管理留言</a></div>
</td>
</tr>
</table>
<p><font size="6"><strong>易巍留言本 </strong></font></p>
<% rs.pagesize=5
totalrecord=rs.recordcount
totalpages=rs.pagecount
maxpages=rs.pagesize
if thepage<1 then
thepage=1
end if
if thepage>totalpages then
thepage=totalpages
end if
if thepage=1 then
showContent
else
if (thepage-1)*maxpages<totalrecord then
rs.move (thepage-1)*maxpages
dim bookmark
bookmark=rs.bookmark
showContent
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
dim k
k=(totalrecord-maxpages*(thepage-1))+1
i=0
do
while not (rs.eof or err)
k=k-1
%>
<table width="62%" border="1" cellspacing="0" cellpadding="0" bordercolor="#6699CC">
<!--循环体开始-->
<tr bgcolor="#3E87F4">
<td colspan="4">
<div align="center"><font color="#FFFFFF"><%=rs("zt")%> </font></div>
</td>
</tr>
<tr>
<td width="17%">
<div align="center"><%=rs("xm")%> </div>
</td>
<td width="23%">  主题:</td>
<td colspan="2"> 留于:<%=rs("ly")%></td>
</tr>
<tr>
<td width="17%">
<div align="center"> <IMG SRC="<%=rs("xx")%>" BORDER="0"></div>
</td>
<td rowspan="2" colspan="3"><%=rs("ny")%></td>
</tr>
<tr>
<td rowspan="2" height="27" width="17%">
<div align="center">来自:<%=rs("lz")%></div>
</td>
</tr>
<tr>
<td width="23%" height="26">  <a href="mailto:<%=rs("yj")%>"><img src="images/email.gif" width="16" height="16" border="0">
</a>
<% if rs("zy")="" then
%>
<img src="images/home.gif" width="0" height="0" border="0">
<% else
%>
<a href="<%=rs("zy")%>"><img src="images/home.gif" width="16" height="16" border="0">
</a>
<% end if %>
<% if rs("qq")="" then
%>
<% else
%>
<a href="http://search.tencent.com/cgi-bin/friend/user_show_info?ln=<%=rs("QQ")%>"><img src="images/oicq.gif" width="16" height="16" border="0"></a>
<% end if %>
</td>
<td width="31%" height="26">&amp;nbsp;</td>
<td width="29%" height="26">&amp;nbsp;</td>
</tr>
</table>

<table width="79%" border="0" cellspacing="0" cellpadding="0">
<%
sql2="select * from hh where TID="&amp;rs("id")
Set rs1=Server.CreateObject("ADODB.Recordset")
rs1.open sql2,conn
%>
<tr>
<td>
<% if rs1.eof or rs1.bof then
%>
<% else
%>

<table width="124%" border="1" cellspacing="1" cellpadding="1" bordercolor="#0099FF">
<tr>
<td height="33" width="19%">
<div align="center">版主回复</div>
</td>
<td height="33" width="81%"><%=rs1("nr")%></td>
</tr>
</table>
<% end if %>
</td>
</tr>

</table>
<%
i=i+1
if i>=Maxpages then
exitdo

rs.movenext
loop
end sub
%>
<p align="center">版本:<a href="http://asp3.6to23.com/bwcweb/down/list.asp?id=30">yiwei
GuestBook v1.6</a></p>
<p align="center">版权所有: <a href="http://ywasp.6to23.com">编程网</a>     制作:ywasp</p>
<p>&amp;nbsp;</p>
</div>
<tr>
<% If thepage<1 then
%>
<% else
%>
<!--分页程序开始-->
<td width="592" height="22" class="jnfont1" style="border-left-style: solid;
border-left-width: 1;
border-right-style: solid;
border-right-width: 1;
border-top-width: 1;
border-bottom-style: solid;
border-bottom-width: 1">
<p align="right">
<% ShowPages %>
</td>
</tr>
<!--分页程序结束-->
<% End If
response.write " </table></center></div>"
%>

<p>
<%
Sub showpages
If thepage <> 1 then
Response.Write "<A HREF=default.asp>【第一页】</A>"
Response.Write "<A href=default.asp?Page=" &amp;
(thepage-1) &amp;
">【上一页】</A>"
End If
If thepage <> totalpages then
Response.Write "<A href=default.asp?Page=" &amp;
(thepage+1) &amp;
">【下一页】</A>"
Response.Write "<A HREF=default.asp?Page=" &amp;
totalPages &amp;
">【最后一页】</A>"
Response.Write "【共<font color=#ff0000>" &amp;
totalpages &amp;
"</font>页】"
End If
End Sub
%></html>
 
T

tianjh007

Unregistered / Unconfirmed
GUEST, unregistred user!
这个有什么好说的
就是因为它在程序中多次需要用到showContent过程中的代码,所以写了个过程来调用嘛
没什么啊
 
F

fly555

Unregistered / Unconfirmed
GUEST, unregistred user!
说了这么多,
没进入实质,
我是说你们要是可以看懂两个过程内部的流程,
特别是它的算法及怎样实现的?
 
T

tianjh007

Unregistered / Unconfirmed
GUEST, unregistred user!
看来看去实在不知内部流程里边有什么算法
就是几个循环嘛
最基本的语法啦
不要想太复杂了
 
A

Activer

Unregistered / Unconfirmed
GUEST, unregistred user!
看完之后 有点糊涂 不明白什么叫算法了
感觉这种东西 就是一段程序
如果这种也叫算法
我也可以出几本算法导论之类的书了
 
F

fly555

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 

Similar threads

顶部