我正在尝试创建一个线程讨论,我很难编写它。
以下是我的MSSQL服务器表结构:
replyID (auto int)
superID
parentID
childID
date
lineage (hex value of path for sorting purposes)
path
body, etc...
以下是没有对分类目的不重要的字段的示例数据:
我包括日期,血统和路径以供参考。
注意:我正在排序superID desc,lineage asc:
rid sid pid cid date lineage path
84 84 0 0 2014-05-13 05:23:05.860 0x /
85 84 84 0 2014-05-13 05:23:34.707 0xE00652 /84/0/
86 84 85 1 2014-05-13 05:23:58.383 0xE0067801B580 /84/85/1/
87 84 85 1 2014-05-13 05:24:11.567 0xE0067801B580 /84/85/1/
88 84 86 2 2014-05-13 05:24:24.580 0xE0067801BE0075A0 /84/85/86/2/
76 76 0 0 2014-05-13 04:43:20.483 0x /
77 76 76 0 2014-05-13 04:43:34.837 0xDB9480 /76/0/
78 76 77 1 2014-05-13 04:44:13.390 0xDB9DBB58 /76/77/1/
79 76 77 1 2014-05-13 04:45:30.500 0xDB9DBB58 /76/77/1/
80 76 78 2 2014-05-13 04:45:45.303 0xDB9DBBDBD680 /76/77/78/2/
82 76 78 2 2014-05-13 04:56:03.090 0xDB9DBBDBD680 /76/77/78/2/
81 76 80 3 2014-05-13 04:46:36.930 0xDB9DBBDBDE0045E0 /76/77/78/80/3/
83 76 79 2 2014-05-13 04:58:14.163 0xDB9DBBDBF680 /76/77/79/2/
75 75 0 0 2014-05-13 04:43:02.253 0x /
使用条件语句,如何使用经典ASP创建基于此结构的树视图线程消息输出?
请告知。
有人提到要显示我到目前为止所做的事情。问题是我在下面有意无效,因为我正在对它进行故障排除,我只想得到一个简单的布局。
将此转换为树结构是个问题。
顺便说一下,如果有任何帮助,我会使用Bootstrap 3。
set RSDetails= Server.CreateObject("ADODB.Recordset")
mySQL = "SELECT a.item_replyid,a.item_superid,a.item_parentid,a.item_childid,a.item_replyunique,a.item_topicid,a.item_replydate,a.item_replyuser,a.item_reply,a.item_lineage,a.item_lineage.ToString() AS path,a.item_r_rate,b.id,b.user_unique,b.username,b.auth_image" _
& " FROM item_replies AS a, item_users AS B " _
& " WHERE a.item_topicid = '" & pidarticle & "'" _
& " AND a.item_replyuser = b.ID " _
& " AND a.item_replyactive = 1 " _
& " ORDER BY a.item_superid DESC, a.item_lineage ASC;"
'response.write mySQL&"<hr>"
RSDetails.CursorLocation = 3 'adUseClient
RSDetails.Open mySQL, adoCon, 3, 1, 1
IF Not RSDetails.EOF THEN
arrDetails=RSDetails.GetRows()
errDetails=0
numRecords=RSDetails.RecordCount
ELSE
errDetails=1
END IF
RSDetails.Close
<ul class="media-list">
<%
'response.write "PIisless is " & PIisless & "<hr>"
prevparent = -1
For iDetails = (PageSize*(PageIndex-1)) to PIisless
acommentid = arrDetails( 0, iDetails )
acommentsuper = arrDetails( 1, iDetails )
acommentparent = arrDetails( 2, iDetails )
acommentchild = arrDetails( 3, iDetails )
acommentunique = arrDetails( 4, iDetails )
comment_date = arrDetails( 6, iDetails )
comment_userid = arrDetails( 7, iDetails )
comment_text = arrDetails( 8, iDetails )
path = arrDetails( 10, iDetails )
item_r_rate = arrDetails( 11, iDetails )
user_unique = arrDetails( 13, iDetails )
comment_username = arrDetails( 14, iDetails )
auth_icon = arrDetails( 15, iDetails )
abuseurl = "Abuse: "&pidarticle&"/"&acommentid&""
abuseurl = Server.URLEncode(abuseurl)
if Len(auth_icon)>0 then
imagesize = "s144"
item_image = "<a class=""pull-left"" href=""http://fakedomain.com/b/"&comment_userid&"/"&FormatTitle(comment_username)&"""><img src="""&resize(auth_icon,imagesize)&""" border=""0"" class=""media-object""/></a>"
else
item_image = ""
end if
if (acommentsuper <> prevsuper) then
%>
<li class="media">
<% end if
if acommentparent <> prevsuperid then %>
<div class="reply"><div class="ui-group-buttons pull-left">
<% if showrank=1 then %><a href="javascript:makeRequest('http://fakedomain.com/queryrate.asp?id=<%=acommentunique%>&p1=1&m1=0&r=1&t=0&m=<%=vmember_unique%>&a=<%=user_unique%>');" class="btn btn-success" role="button"><span class="glyphicon glyphicon-thumbs-up"></span></a><% end if %>
<div><span id="RATING_<%=acommentunique%>" class="rank"><%=item_r_rate%></span></div>
<% if showrank=1 then %> <a href="javascript:makeRequest('http://fakedomain.com/queryrate.asp?id=<%=acommentunique%>&p1=0&m1=1&r=1&t=0&m=<%=vmember_unique%>&a=<%=user_unique%>');" class="btn btn-danger" role="button"><span class="glyphicon glyphicon-thumbs-down"></span></a><%end if %></div>
<%=item_image%>
<div class="media-body">
<a name="<%=acommentunique%>"></a>
<% end if %>
<% if acommentparent = prevsuperid then %>
<!-- Nested media object -->
<div class="plain media">
<div class="reply"><div class="ui-group-buttons pull-left">
<% if showrank=1 then %><a href="javascript:makeRequest('http://fakedomain.com/queryrate.asp?id=<%=acommentunique%>&p1=1&m1=0&r=1&t=0&m=<%=vmember_unique%>&a=<%=user_unique%>');" class="btn btn-success" role="button"><span class="glyphicon glyphicon-thumbs-up"></span></a><% end if %>
<div><span id="RATING_<%=acommentunique%>" class="rank"><%=item_r_rate%></span></div>
<% if showrank=1 then %> <a href="javascript:makeRequest('http://fakedomain.com/queryrate.asp?id=<%=acommentunique%>&p1=0&m1=1&r=1&t=0&m=<%=vmember_unique%>&a=<%=user_unique%>');" class="btn btn-danger" role="button"><span class="glyphicon glyphicon-thumbs-down"></span></a><%end if %></div>
<%=item_image%>
<div class="media-body">
<a name="<%=acommentunique%>"></a>
<%end if %>
<h4 class="media-heading"><% if comment_name<>"" then %><%=comment_name%><% else %><a href="../../b/<%=FormatTitle(comment_username)%>"><%=comment_username %><% end if%> said:</a></h4>
<a name="<%=acommentid%>"></a><%=(comment_text)%>
<div id="reply"><a href="../../newreply.asp?insert=add&recid=<%=acommentunique%>&tid=<%=item_uniqueid%>&gid=<%=group_unique%>&cid=<%=acommentchild%>" class="Butt">Reply</a> | <% if (cuser_unique = comment_userid) or (Session("priv")="1") or (comment_userid = Session("id")) then %><a href="../../newreply.asp?action=edit&recid=<%=acommentunique%>&gid=<%=group_unique%>">Edit</a> | <a href="../../newreply.asp?action=edit&recid=<%=acommentunique%>&gid=<%=group_unique%>&redir=<%=redir%>#commentstop">Delete</a> | <% end if %><%=TimeSince(comment_date)%> | <a href="../../contact.asp?emailSubject=<%=abuseurl%>" class="report">Report</a> | P: <%=acommentparent%> C: <%=acommentchild%> Path: <%=path%> | acommentparrent: <%=acommentparent%> prevparent: <%=prevcomment%> | super/parent/child <%=acommentsuper%>/<%=acommentparent%>/<%=acommentchild%></div><!--reply-->
<% if acommentparent = prevparent then %>
</div><!--media-body-->
</div><!--reply-->
</div><!--plain media-->
<% end if %>
<% if acommentparent <> prevparent then %>
</div><!--media-body-->
</div><!--reply-->
<% end if
if (acommentsuper <> prevsuper) then %>
</li><!--media-->
<% end if
prevcomment = acommentparent
prevsuper = acommentsuper
prevparent = acommentparent
prevchild = acommentchild
Next
Set arrDetails = nothing
%>
</ul><!--medialist-->
基于以上数据,输出应该是什么样的:
Reply A
|_reply 1
|_reply 2
|_reply 3
|_reply 4
Reply B
|_reply 1
|_reply 2
|_reply 3
|_reply 4
|_reply 5
|_reply 6
|_reply 7
Reply C