Sort by to solve the "top and bottom topics" issue

Source: Internet
Author: User
Tags chr mail sort
Solve | sort | problem


Many netizens mentioned the forum "on the theme" "The next topic" Display problem, I use another sort of solution, write out, listen to the expert opinion.

Database:

ID: The ID number of the post, automatic numbering
OrderID: Sorted cardinality, described in detail below
.
.
.
Data:

Main post: The first theme posted OrderID for Aaaaaaz (6 of which is for this page can have a maximum of 999999*26 theme stickers, of course, you can change according to your needs. Z as a sort of identification code, never change. ), the second theme is Aaaaabz, that is, each additional subject is affixed, OrderID up a letter.

Sub Posts: The first child is affixed to the OrderID of the parent, add a bit a in front of Z, the second child is attached to the OrderID of the parent, add a bit B to the front of Z, and so on. In other words, the same layer of posts, each additional one, OrderID up a letter, ditto, Z will never change.

It can be seen that the same layer of posts Oderid the same number of digits, and the reply to the same topic, OrderID the first n-bit the same; Thus, the number of layers can be derived from the number of OrderID, and the overall ranking of posts by OrderID Desc, and the last topic is a character minus one, The next subject is the word alphanumeric a slightly! Statement by: add_massege.asp

------------part, without optimal finishing------------

<body bgcolor= "#C8C8E6" >
<script language= "VBScript" >
Sub GoBack ()
Form1.btn1.value= "Back"
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 "Only members can use this feature, please register or login!" <p> "
Response.Write "<a href=main1.htm> back on page </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 "Please fill in your name/password ~ <p>"
%>
<form name=form1>
<input type= "button" Name= "Btn1" value= "return" >
</form>
<%
Response.End
End If
If name<>name1 Or PSW&LT;&GT;PSW1 Then
Response.Write "<font size=5 color=blue><center>"
Response.Write "<br>"
Response.Write "<br>"
Response.Write "Your name/password has errors, please carefully fill in!" ~ <p> "
%>
<form name=form1>
<input type= "button" Name= "Btn1" value= "return" >
</form>
<%
Response.End
End If
If subject= "" Then
Response.Write "<font size=5 color=blue><center>"
Response.Write "<br>"
Response.Write "<br>"
Response.Write "Please fill in your speech theme ~ <p>"
%>
<form name=form1>
<input type= "button" Name= "Btn1" value= "return" >
</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)};d bq=" & DBPath
Set RS = conn. Execute ("Select A_id,a_orderid from Massege")
Do but 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)};d bq=" & 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))
%>
&LT;%=CHR (a)%>11<%=chr (b)%&GT;22&LT;%=CHR (c)%&GT;33&LT;%=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)};d bq=" & 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>

Show: (sort) main.asp

--------part, not optimized for processing-------

<%
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)};d bq=" & 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>
&LT;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" > Statements </ Font></a></td>
&LT;TD style= "Border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><a href=" main.asp "><font color=" #0000FF "> Refresh </font></a> </td>
&LT;TD height= "1" style= "border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><font color=" #0000FF "> Message number: <%=rs. Recordcount%></font></td>
&LT;TD height= "1" style= "border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><font color=" #0000FF > Total Pages: <%=rs. Pagecount%></font></td>
&LT;TD height= "1" style= "border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><font color=" #0000FF "> Current page:<%=page%></font></td>
&LT;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" > Go to <input type= "text" name= "Txtpage" size= "2" style= " font-size:8pt; border-style:dotted; Border-width:1 "> Page </font></td>
&LT;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> first page </a>"%></font></td>
&LT;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) & "> Prev </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) & "> Next page </a>"%></font></td >
&LT;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& "> Last page </a>"
End If
%></font></td>
&LT;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" > Essence </font></ A></td>
&LT;TD style= "Border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><a href=" baoqian.htm "><font color=" #0000FF "> Search </font></a ></td>
<%
If application ("Ukingliu") = "Kingliu" Then
Aaa= "On"
Else
Aaa= "Off"
End If
%>
&LT;TD style= "Border-left:1 solid #FFFF00; Border-right:1 solid #FFFF00; Border-bottom:2 solid #FFFF00 "><font color=" #0000FF "> This edition: <a href=" mailto:kingliuzk@chinaren.com "> The sea for water </a>.gif" width= "height=" ></ Font></td>
</tr>
</table>
</form>
<%for ipage = 1 to RS. Pagesize%>
.
.
.
(indent, omit)
Face=rs ("A_face")
mmm=gif& "" &face& ". gif"
%>
<table align= "center" border= "0" cellspacing= "1" width= "750" bgcolor= "#BEBEDC" >
<tr>
&LT;TD style= "border-bottom:1 solid #FFFF00" ><%=aaa%>
<ul>
<li> "><a href=" Massege.asp?txtid=<%=rs ("a_id")%> "target=" Rbottom "><%=" Server.HTMLEncode (RS ("A_subject"))%></a>
<%
If RS ("a_text") = "" Then
Response.Write "< no content >"
End If
%>
{Id:<%=rs ("a_id")%>} "<%=rs (" A_name ")%>id:<%=rs (" A_nid ")%>" <<%=rs ("A_time")%>> " Click: <%=rs ("A_times")%> "</td>
</tr>
</table>
<%
Rs. MoveNext
If RS. EOF Then Exit for
Next
Rs. Close
Conn. Close




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.