排序方式解決“上下主題”問題

來源:互聯網
上載者:User
解決|排序|問題


來不少網友提到論壇“上一主題”“下一主題”的顯示問題,我使用另一種排序方式解決的,寫出來,聽聽高手的意見。

資料庫:

ID:貼子的id號,自動編號
OrderID:排序基數,以下詳細描述
.
.
.
資料:

主體貼:第一個主題貼OrderID為aaaaaaz(其中的6個a是為了這個版面上最多可以有999999*26條主題貼,當然,您可以根據自己的需要更改。z作為排序的識別碼,永遠無變化。),第二個主題貼為aaaaabz,就是說,每增加一個主題貼,OrderID上漲一個字母。

子帖:第一個子貼在父貼的OrderID的基礎上,在z前面增加一位a,第二個子貼在父貼的OrderID的基礎上,在z的前面增加一位b,以此類推。也就是說,同一層的貼子,每增加一個,OrderID上漲一個字母,同上,z永遠不變。

可以看出,同一層的貼子OderID的位元相同;而回複同一主題的貼子,OrderID的前n位相同;這樣,貼子所在層數可以由OrderID的位元得出;而貼子的總體排序by OrderID desc;而上一主題貼就是字元減一,下一主題貼就是字元加一咯! 發言:add_massege.asp

------------部分,未經最佳化整理------------

<body bgcolor="#C8C8E6">
<script language="VBScript">
Sub GoBack()
form1.btn1.value="返回"
history.go(-1)
end sub
</Script>
<%
name1=Session("Uname")
If name1="" Then
Response.Write"<font size=3 color=blue><center>"
Response.Write"<br>"
Response.Write"<br>"
Response.Write"只有會員才能使用此項功能,請您註冊或登入! <p>"
Response.Write"<a href=main1.htm>回上頁</a>"
Response.End
End If
psw1=Session("Upsw")
orderid=Request("txtOrderid")
face=Request("R1")
level=Request("txtLevel")
name=Request("txtName")
psw=Request("txtPsw")
work=Session("Uwork")
add=Session("Uadd")
eee=Session("Unid")
mail=Request("txtMail")
subject=Request("txtSubject")
ip=Request.ServerVariables("Remote_Addr")
If name ="" OR psw ="" Then
Response.Write"<font size=5 color=blue><center>"
Response.Write"<br>"
Response.Write"<br>"
Response.Write"請填寫你的名字/密碼~ <p>"
%>
<form name=form1>
<input type="button" name="btn1" value="返回" >
</form>
<%
Response.End
End If
If name<>name1 Or psw<>psw1 Then
Response.Write"<font size=5 color=blue><center>"
Response.Write"<br>"
Response.Write"<br>"
Response.Write"您的名字/密碼有錯誤,請仔細填寫!~ <p>"
%>
<form name=form1>
<input type="button" name="btn1" value="返回" >
</form>
<%
Response.End
End If
If subject="" Then
Response.Write"<font size=5 color=blue><center>"
Response.Write"<br>"
Response.Write"<br>"
Response.Write"請填寫您的發言主題~ <p>"
%>
<form name=form1>
<input type="button" name="btn1" value="返回" >
</form>
<%
Response.End
End If
IF orderid<>"" Then
j=Len(orderid)
mmm=Left(orderid,j-1)
Set conn = Server.CreateObject("ADODB.Connection")
DBPath=Server.MapPath("../fpdb/massege.mdb")
conn.Open"Driver={Microsoft Access Driver (*.mdb)};dbq="& DBPath
Set RS = conn.Execute("Select A_ID,A_OrderID From MASSEGE")
DO While not RS.EOF
nnn=RS("A_OrderID")
If Left(nnn,j-1)=mmm Then
aaa=Asc(Mid(nnn,j,1))
If aaa=122 Then
qqq=mmm+"a"+"z"
Else
qqq=mmm+Chr(aaa+1)+"z"
End If
End If
RS.MoveNext
Loop
RS.Close
conn.Close
Else
Set myconn = Server.CreateObject("ADODB.Connection")
DBPath=Server.MapPath("../fpdb/massege.mdb")
myconn.Open"Driver={Microsoft Access Driver (*.mdb)};dbq="& DBPath
SQLcmd1="Select * From MASSEGE Where A_Level = '0' Order By A_ID DESC"
Set RS = myconn.Execute(SQLcmd1)
nnn=RS("A_OrderID")
a=Asc(Left(nnn,1))
b=Asc(Mid(nnn,2,1))
c=Asc(Mid(nnn,3,1))
d=Asc(Mid(nnn,4,1))
e=Asc(Mid(nnn,5,1))
f=Asc(Mid(nnn,6,1))
%>
<%=Chr(a)%>11<%=Chr(b)%>22<%=Chr(c)%>33<%=Chr(d)%>44<%=Chr(e)%>55<%=Chr(f)%>66
<%
If f<122 Then
qqq=Chr(a)+Chr(b)+Chr(c)+Chr(d)+Chr(e)+Chr(f+1)+"z"
%>
<%=qqq%>77
<%
Else
If e<122 Then
qqq=Chr(a)+Chr(b)+Chr(c)+Chr(d)+Chr(e+1)+"az"
%>
<%=qqq%>88
<%
Else
If d<122 Then
qqq=Chr(a)+Chr(b)+Chr(c)+Chr(d+1)+"aaz"
%>
<%=qqq%>99
<%
End If
End If
End If
RS.Close
myconn.Close
End if
text=Server.HTMLEncode(Request("txtText"))
%>
<%=text%>
<%On error resume next
Set conn = Server.CreateObject("ADODB.Connection")
DBPath=Server.MapPath("../fpdb/massege.mdb")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};dbq="& DBPath
SQLcmd = "Insert Into MASSEGE(A_OrderID,A_Level,A_Name,A_NID,A_Work,A_Add,A_Mail,A_Subject,A_Text,A_IP,A_Time)Values('"&qqq&"','"&level&"','"&name&"','"&eee&"','"&work&"','"&add&"','"&mail&"','"&subject&"','"&text&"','"&ip&"','"&now&"')"
conn.Execute SQLcmd
conn.Close
Response.Redirect"succ.htm"
%>
</body>

顯示:(排序)main.asp

--------部分,未經最佳化處理-------

<%
Const adOpenStatic = 3
Const adLockPessimistic = 2
Set conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")
DBPath=Server.MapPath("../fpdb/massege.mdb")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};dbq="& DBPath
SQLcmd="Select * From MASSEGE Order By A_OrderID Desc"
RS.Open SQLcmd,conn,adOpenStatic,adLockPessimistic
page = CLng(Request("txtpage"))
RS.PageSize = 30
If Page < 1 Then Page = 1
If page > RS.PageCount Then page = RS.PageCount
RS.AbsolutePage = page
%>
<form action="main.asp" method="get">
<table align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><a href="speak.asp" target="rbottom"><font color="#0000FF">發言</font></a></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><a href="main.asp"><font color="#0000FF">重新整理</font></a></td>
<td height="1" style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF">留言筆數:<%=RS.RecordCount%></font></td>
<td height="1" style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF">總頁數:<%=RS.PageCount%></font></td>
<td height="1" style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF">目前頁次:<%=page%></font></td>
<td valign="top" align="left" height="1" style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF">轉到<input type="text" name="txtpage" size="2" style="font-size: 8pt; border-style: dotted; border-width: 1">頁</font></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00">
<font color="#0000FF">
<%
If page <> 1 Then
Response.Write"<a href=main.asp?txtpage=1>第一頁</a>"%></font></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00">
<font color="#0000FF">
<%Response.Write"<a href=main.asp?txtpage="&(page - 1)&">上一頁</a>"%></font></td>
<%
End If
If page <>RS.PageCount Then%><td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00">
<font color="#0000FF">
<%Response.Write"<a href=main.asp?txtpage="&(page + 1)&">下一頁</a>" %></font></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF"><%Response.Write"<a href=main.asp?txtpage="&RS.PageCount&">最後一頁</a>"
End If
%></font></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><a href="pob_massege.asp"><font color="#0000FF">精華</font></a></td>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><a href="baoqian.htm"><font color="#0000FF">檢索</font></a></td>
<%
If Application("Ukingliu")="kingliu" Then
aaa="on"
Else
aaa="off"
End If
%>
<td style="border-left: 1 solid #FFFF00; border-right: 1 solid #FFFF00; border-bottom: 2 solid #FFFF00"><font color="#0000FF">本版斑竹:<a href="mailto:kingliuzk@chinaren.com">滄海為水</a><img src="http://www.163design.net/a/images/<%=aaa%>.gif" width="15" height="15"></font></td>
</tr>
</table>
</form>
<%For ipage = 1 To RS.PageSize%>
.
.
.
(縮排,省略)
face=RS("A_Face")
mmm=gif&""&face&".gif"
%>
<table align="center" border="0" cellspacing="1" width="750" bgcolor="#BEBEDC">
<tr>
<td style="border-bottom: 1 solid #FFFF00"><%=aaa%>
<ul>
<li><img src="../images/<%=mmm%>"><a href="massege.asp?txtID=<%=RS("A_ID")%>" target="rbottom"><%=Server.HTMLEncode(RS("A_Subject"))%></a>
<%
If RS("A_Text")="" Then
Response.Write"<無內容>"
End If
%>
{ID:<%=RS("A_ID")%>}【<%=RS("A_Name")%>ID:<%=RS("A_NID")%>】<<%=RS("A_Time")%>>『點擊:<%=RS("A_Times")%>』</td>
</tr>
</table>
<%
RS.MoveNext
If RS.EOF Then Exit For
Next
RS.Close
conn.Close




相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。