declare @int_allid int declare @int_beginid int,@int_endid int declare @int_pagebegin int, @int_pageend int
select @int_allid=count(*) from tab_discuss where tint_level=0 and tint_tableid=@tint_tableid select @int_recordcount=@int_allid --得出該版面的總貼數
declare cro_fastread cursor scroll for select int_id from tab_discuss where tint_level=0 and tint_tableid=@tint_tableid order by int_id desc --這里定義游標操作,但是不用臨時紀錄集,而且游標也不需要全部遍歷所有紀錄集。
fetch absolute @int_beginid from cro_fastread into @int_pagebegin 將他的Id傳給一個變量該頁開始的Id if @int_endid>@int_allid --這里要注意,如果某一頁不足固定頁數的紀錄時。如只有一頁紀錄,而且紀錄少于我們定義的數目?;蛘呤亲詈笠豁摃r。。。 fetch last from cro_fastread into @int_pageend --直接將游標絕對定位到最后一條紀錄,得出他的id號來。。。 else fetch absolute @int_endid from cro_fastread into @int_pageend
select int_id,tint_level,tint_children,var_face,var_subject,datalength(txt_content) as int_len,sint_hits,var_url,var_image,var_user,dat_time,tint_tableid,bit_kernul from tab_discuss where tint_tableid=@tint_tableid and int_rootid between @int_pageend and @int_pagebegin order by int_rootid desc,num_order desc --我們就可以利用該頁的第一個id和最后一個id得出中間的id來。。。。(注意。我們這個BBS的數性結構用了一種很巧妙的算法,就是用一個orderNum浮點數即可完成排序。。。)
--開始清場。。。 close cro_fastread deallocate cro_fastread
set rs=cmd.Execute if rs.eof then Response.Write "目前已超過了紀錄個數或紀錄集為空!" Response.End end if
dim arrRs arrRs=rs.getrows '可以利用getRows將紀錄集迅速保存到一個二維的數組中來提高速度。
recordcount=cmd.Parameters("int_recordcount") '注意,當紀錄不足以剛好整除單位頁紀錄時,我們也要將其定義為一頁,如紀錄數目為2頁多一個紀錄,此時我們的頁數也要為3頁紀錄。 if (recordcount mod pagesize)=0 then pagecount=recordcount/pagesize else pagecount=recordcount/pagesize+1 end if
<div align="left" class="pblank" > <% '---------顯示樹性結構!------------- level=0 Response.Write "<ul>" for i=0 to ubound(arrRs,2) if arrRs(1,i)>level then Response.Write "<ul>" end if if arrRs(1,i)<level then for j=arrRs(1,i) to level-1 Response.Write "</ul>" next end if int_size=arrRs(5,i) if int_size=0 then str_size=" <無內容>" else str_size="" end if Response.Write "<li><img src=face/"&arrRs(3,i)&"><a href=showTitle.asp?int_id="&arrRs(0,i)&"&tint_tableid="&tint_tableid&" class=ptitle target=BoardAnnounce>"&server.HTMLEncode(arrRs(4,i))&"</a> "&str_size if arrRs(7,i)<>"" then Response.Write " <連接> " if arrRs(8,i)<>"" then Response.Write " <圖像> " Response.Write " -【"&arrRs(9,i)&"】 <font color=444444>"&arrRs(10,i)&"</font> [<font color=920092>ID:"&arrRs(0,i)&" 點擊:"&arrRs(6,i)&"次</font>] <font color=444444>("&int_size&"字節)</font> <font color=ff0000>("&arrRs(2,i)&")</font></li>"