用排序串字段实现树状结构(例程——显示树)

程序index.asp
功能:显示目录树

 1   
 2pageno=request("pageno")   
 3searchtype=request("searchtype")   
 4searchnr=rtrim(request("searchnr"))   
 5set guestconn=Server.CreateObject("ADODB.connection")   
 6guestconn.Open lybstr   
 7set guestrs=server.createobject("ADODB.recordset")   
 8sqlstr="SELECT * FROM guestbook"   
 9if searchnr<>"" then sqlstr=sqlstr&" where "&searchtype&" like '%%"&replace(searchnr,"'","''")&"%%'"   
10sqlstr=sqlstr&" order by rootid+(1-sign(rootid))*lybid desc,orderstr,lybid desc"   
11guestrs.open sqlstr,guestconn,1,1   
12rowcount=25   
13if pageno="" then pageno=1   
14if not guestrs.eof then   
15if IsNumeric(pageno) then   
16guestrs.pagesize=rowcount   
17if pageno+1>guestrs.pagecount+1 then pageno=guestrs.pagecount   
18else   
19pageno=1   
20end if   
21guestrs.AbsolutePage=pageno   
22else   
23pageno=1   
24end if   
 1<html>
 2<head><title>软件使用留言薄</title>
 3<style type="text/css">   
 4<!--   
 5a { text-decoration: none}   
 6body {line-height:18px;font-size:9pt;font-family:宋体}   
 7a:hover {color:#FF0000;text-decoration:none}   
 8.submit {line-height:9pt;font-size:9pt;font-family:宋体}   
 9.submit1 {line-height:8pt;font-size:8pt;font-family:宋体}   
10.selectform {font-family: 宋体; font-size: 9pt;background-color:ffE4E4}   
11td {font-family: 宋体; font-size: 9pt;background-color:ECF7FF}   
12.td1 {font-family: 宋体; font-size: 9pt;background-color:A2C8F2}   
13.td2 {font-family: 宋体; font-size: 9pt;background-color:E9EDE0}   
14.small1 {font-family: 宋体; font-size: 9pt;background-color:ffffff;line-height:9pt}   
15\-->   
16</style>
17<script language="JavaScript1.2">   
18function d(sp,t,a,d,ti,l,id,rid,pn)   
19{   
20document.write("<tr><td>"+sp+"<a href='disprec.asp?   
21keyid="+id+"&rootid="+rid+"&pageno="+pn+"'>"+t+"</a></td>");   
22document.write("<td align=right>"+a+" </td>");   
23document.write("<td nowrap align=center>"+d+" "+ti+"</td>");   
24document.write("<td align=right>"+l+" </td>");   
25document.write("<td align=right>"+id+" </td>");   
26document.write("</tr>");   
27}   
28</script>
29</head>
30<body topmargin="16">
31<form action="index.asp" method="POST" name="index">
32<table align="center" width="100%">
33<tr>
34<td align="center" height="35" style="font-size:16px;background-color:ffffff;color:red" valign="top">软件使用   
35留言薄</td>
36<td align="center" colspan="3" style="font-size:13px;background-color:ffffff" valign="bottom">共<font style="font-size:16px;color:red">```
37 =guestrs.recordcount 
38```</font>条留言<font style="font-   
39size:16px;color:red">```
40 =guestrs.pagecount 
41```</font>页目前第<font style="font-size:16px;color:red">```
42   
43=pageno 
44```</font>页</td>
45<td style="background-color:ffffff" valign="bottom"><a href="/wen/swuselyb/index.asp">旧留言薄   
46</a></td></tr>
47<tr>
48<td align="center" class="td2">搜索贴子   
49<select class="small1" name="searchtype">
50<option ```="" if="" response.write("selected")="" searchtype="guestname" then="" value="guestname"&gt;贴子作者   
51
52&lt;option ```="" if="" response.write("selected")="" searchtype="guestcomm" then="" value="guestcomm">贴子内容   
53
54</option></option></select> <input class="small1" name="searchnr" size="14" type="text" value="```
55 =searchnr 
56```"/> <a href="javascript:document.index.submit();">开始搜索</a>
57</td>
58<td align="center" class="td2" colspan="3">```
59 if pageno+1&amp;gt;2 then 
60```<a href="javascript:document.index.pageno.value--;document.index.submit();">上一页</a>```
61 else 
62```上一页```
63 end   
64if 
65``` ```
66 if pageno+1&lt;guestrs.pagecount+1 ```<a="" href="javascript:document.index.pageno.value++;document.index.submit();" then="">下一页```
67 else 
68```下一页```
69 end   
70if 
71``` 到<input =pageno="" ```="" class="small1" name="pageno" size="6" type="text" value="```"/>页</guestrs.pagecount+1></td>
72<td align="center" class="td2"><a href="revert.asp?type=post">发贴子</a></td>
73</tr>
74<tr style="color:red">
75<td align="center" class="td1">留言标题</td>
76<td align="center" class="td1" width="70"><img src="edit.gif"/>作 者</td>
77<td align="center" class="td1" width="100">发表时间</td>
78<td align="center" class="td1" nowrap="" width="60">贴子字数</td>
79<td align="center" class="td1" nowrap="" width="60">贴子序号</td>
80</tr>   

do while true
if guestrs.eof then exit do
if guestrs("rootid")=0 then exit do
guestrs.movenext
loop
do while not guestrs.eof and rowcount&gt;0 <script>d(' =replace(space(2*len(guestrs
("orderstr")))," "," ") ',' =guestrs("guestitle") ',' =guestrs("guestname") ',' =guestrs
("putdate") ',' =guestrs("puttime") ', =len(guestrs("guestcomm")) , =guestrs("lybid") ,

=guestrs("rootid") , =pageno

rowcount=rowcount-1
guestrs.movenext
if not guestrs.eof then
if guestrs("rootid")&lt;&gt;0 and rowcount=0 then rowcount=1
end if
loop
guestrs.close
set guestrs=nothing
guestconn.close
set guestconn=nothing

1</table>
2</form>
3<br/><br/><br/>
4</body>
5</html>
Published At
Categories with Web编程
comments powered by Disqus