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

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

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

Developer : kyduke(kyd...@yahoo.com) - Asp Programer

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
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

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
writing : kyduke_num = bigest kyduke_num + 100

DB table fields
num : physical record number
kyduke_num : kyduke(kyd...@yahoo.com)'s new int field
group : article's group#

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.

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.

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

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

<%
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.

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

<%
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

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
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.

<%
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...
3. deleteing and rooping parent's article that

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

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
7. Bug reporting
Mail to kyd...@yahoo.com

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------
It is kyduke(kyd...@yahoo.com)'s New Logic