kyduke(kyduke@yahoo.com)'s New Logic - New sorting, New paging method 
Author Message
 kyduke(kyduke@yahoo.com)'s New Logic - New sorting, New paging method


paging method


-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
1. INTRO
(1) NEW paging method Using rs.PageSize, rs.AbsolutePage
(2) Page Number Link -> page moving
[pre] [101] [102] ... [110] [next]
(3)USING kyduke_num
"kyduke_num" id new int field.
sorting : ORDER BY kyduke_num DESC

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
2. write & reply
writing : kyduke_num = bigest kyduke_num + 100
available reply count : 99

DB table fields
num : physical record number

group : article's group#
depth : reply depth

First 1 article writing...

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1

Second...

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1
  2       200          2        1

Parent article has depth=1, kyduke_num=bigest
kyduke_num+100 and group=bigest num+1.

Writing num=1 article's reply.

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1
  2       200          2        1
  3        99          1        2

num=3 aricle has kyduke_num=parent article(1,100,1,1)'s
kyduke_num -1, group=parent's group, depth=parent's
depth+1.

More reply...

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1
  2       200          2        1
  3        98          1        2
  4        99          1        2

num=4 article has kyduke_num=parent article(1,100,1,1)'s
kyduke_num -1, group=parent's group, depth=parent's
depth+1.

num=3 article has kyduke_num <= num=4 article's kyduke_num.
Updating kyduke_num=kyduke_num-1 WHERE kyduke_num <=
(num=4 article's kyduke_num) AND group=(num=4 article's
group).

PA 2 (2,200,2,1)
PA 1 (1,100,1,1)
  |- R2 (4,99,1,2)
  |- R1 (3,98,1,2)

Sorting : ORDER BY kyduke_num DESC

Reply's Reply...

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1
  2       200          2        1
  3        98          1        2
  4        99          1        2
  5        97          1        3

PA 2 (2,200,2,1)
PA 1 (1,100,1,1)
  |- R2 (4,99,1,2)
  |- R1 (3,98,1,2)
       |- R11 (5,97,1,3)

More articles...

num    kyduke_num    group    depth
-----------------------------------
  1       100          1        1
  2       200          2        1
  3        97          1        2
  4        99          1        2
  5        96          1        3
  6       199          2        2
  7        98          1        3
  8       300          8        1

PA 3 (8,300,8,1)
PA 2 (2,200,2,1)
  |- R1 (6,199,2,2)
PA 1 (1,100,1,1)
  |- R2 (4,99,1,2)
  |    |-R21 (7,98,1,3)
  |- R1 (3,97,1,2)
       |- R11 (5,96,1,3)

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
3. bug protecting
If you want reply's count=10, it's OK.

Writing... kyduke_num=(bigest kyduke_num) + 10

<%
Set rs=Server.CreateObject("ADODB.Recordset")
Sql="SELECT num FROM board_table WHERE group=" & Request
("group")
rs.Open Sql...

ThisGroupCount=rs.RecordCount

rs.Close
Set rs=nothing

If ThisGroupCount>=10 then Response.Redirect "error.asp?
massage=overflow~."
%>

OR If exist group's last reply( kyduke_num=1 or 11,
21...), then do not allow reply.

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
4. Listing this page

<%
Set rs=Server.CreateObject("ADODB.Recordset")
If Request("TenThousandLast")="" then
 Sql="SELECT TOP 10000 kyduke_num FROM board_table ORDER
BY kyduke_num DESC"
Else
 Sql="SELECT TOP 10000 kyduke_num FROM board_table WHERE
kyduke_num<" & Request("TenThousandLast") & "
ORDER BY kyduke_num DESC"
End If

rs.PageSize=20
rs.Open Sql...

If Request("page")="" then
 kyduke_ThisPage=1
Else
 kyduke_ThisPage=Request("page")
End If
rs.AbsolutePage=kyduke_ThisPage

kyduke_ThisPageTop=rs(0)

rs.Close

Sql="SELECT TOP 20 * FROM board_table WHERE kyduke<=" &
kyduke_ThisPageTop & " ORDER BY kyduke_num DESC"
rs.Open Sql...

Do until rs.EOF

'Listing articles...

rs.MoveNext
Loop

rs.Close
Set rs=nothing
%>

SELECT TOP 20 * FROM board_table WHERE
kyduke_num<=kyduke_ThisPageTop ORDER BY kyduke_num DESC

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
5. Linking next pages
TOP 10000, if RecordCount is 9010, then last page is 450
page.
9010/20=450

if RecordCount is 10000 ( TOP 10000), then 1~500 pages
exist AND more...

<a href="list.asp?page=1">1</a>
...
<a href="list.asp?page=500">500</a>
<a href="list.asp?page=1&TenThousandLast=<%
=TenThousandLast%>">501</a>
<a href="list.asp?page=2&TenThousandLast=<%
=TenThousandLast%>">502</a>
...
<a href="list.asp?page=499&TenThousandLast=<%
=TenThousandLast%>">999</a>
<a href="list.asp?page=500&TenThousandLast=<%
=TenThousandLast%>">1000</a>

TenThousandLast is 20000th article's kyduke_num.
501 page has Request("page")=1.
10001th~20000th article's first page.

<%
TenThousandLast=Request("TenThousandLast")
Sql="SELECT TOP 10000 kyduke_num FROM ??? WHERE
kyduke_num<" & TenThousandLast & " ORDER BY
kyduke_num DESC"
rs.Open Sql...
rs.MoveLast
If rs.RecordCount=10000 then TenThousandLast2=rs.Fields
("kyduke_num")
rs.Close
%>

<a href="list.asp?page=1&TenThousandLast2=<%
=TenThousandLast2%>">1001</a>
...
<a href="list.asp?page=500&TenThousandLast279=<%
=TenThousandLast279%>">140000</a>
<a href="list.asp?page=1&TenThousandLast280=<%
=TenThousandLast280%>">140001</a>
...

(page#-1)/500 = TenThousandLast's suffix
500 is 10000/20.

ex) 130091 page

(130091-1)/500 = 260.18 --> TenThousandLast260

<a href="list.asp?page=91&TenThousandLast260=<%
=TenThousandLast260%>">130091</a>

Finding TenThousandLast260...

<%
TenThousandLast259=Request("TenThousandLast259")
Sql="SELECT TOP 10000 kyduke_num FROM board_table WHERE
kyduke_num<" & TenThousandLast259 & " ORDER BY
kyduke_num DESC"
rs.Open Sql...
rs.MoveLast
If rs.RecordCount=10000 then TenThousandLast260=rs.Fields
("kyduke_num")
rs.Close
%>

If not exist TenThousandLast259, then looping 260 times or
2600000's article's kyduke_num.

<%
Sql="SELECT TOP 2600000 kyduke_num FROM board_table WHERE
kyduke_num<" & TenThousandLast & " ORDER BY
kyduke_num DESC"
rs.Open Sql...
rs.MoveLast
If rs.RecordCount=10000 then TenThousandLast2=rs.Fields
("kyduke_num")
rs.Close
%>

130091 page's listing 20 article.

<%
Set rs=Server.CreateObject("ADODB.Recordset")
Sql="SELECT TOP 10000 kyduke_num FROM board_table WHERE
kyduke_num<" & Request("TenThousandLast260") & "
ORDER BY kyduke_num DESC"
rs.PageSize=20
rs.Open Sql...

kyduke_ThisPage=Request("page")
rs.AbsolutePage=kyduke_ThisPage

kyduke_ThisPageTop=rs(0)

rs.Close

Sql="SELECT TOP 20 * FROM board_table WHERE kyduke<=" &
kyduke_ThisPageTop & " ORDER BY kyduke_num DESC"
rs.Open Sql...

Do until rs.EOF

'listing articles...

rs.MoveNext
Loop

rs.Close
Set rs=nothing
%>

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
6. Delete article

Three way...

1. deleteing...
2. updateing "this article's removed..."
3. deleteing and rooping parent's article that
updated "this article's removed...".

And updating articles has kyduke_num+1 WHERE kyduke_num<
(deleted article's kyduke_num).

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
7. Bug reporting

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------



Fri, 02 Jan 2004 10:14:30 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. New New New

2. WTL - Very new to WTL - Trying to insert new COM object in WTL

3. COM-new method

4. C# Won't recognize new method(?)

5. How to derive new ATL COM class from ADO's _Recordset

6. How to derive new ATL COM from ADO's Recordset

7. Ideas for new project- new to C++

8. Winsock 2 new functions and new structures

9. Capturing new words into a new string

10. HELP: A new Interface or a New object?

11. New interface = new guid

 

 
Powered by phpBB® Forum Software