查看完整版本: 用文本 ASP打造新闻发布系统(三)新闻列表显示

豹子 2007-6-23 10:29

用文本 ASP打造新闻发布系统(三)新闻列表显示

%
X;mvJ kL3x;Jm dim myfso,myread"p9`8GW)a {g
set myfso=createobject("scripting.filesystemobject")
9?9q.S oIX$K set myread=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)?5ZZ e2tvm4S4{&y]
-B"T)W2CY$O
if myread.atendofstream then
!m6V+F-gwd j Q Response.Write "目前没有添加新闻"
,FB)mGO9OyEP Response.End
B N4fU)G~p_ else!EmK"_5}:p/Cdf)D

k$Fbt2RZ y'c0\ dim mytext,listarray|E,v3s-pWx%O.z
mytext=myread.readall'K,{ SvPa\$Z
listarray=split(mytext,"|") '#######把所有记录分割成一个数组a
ItH2b0m9^ Z^#P BU,F
!ch+[H8@:v(z @
  y4|!W)rF3Z
@ gB(_@
dim recordcount,pagecount, pagesize, pagenum
,o*x&p%]^S recordcount=ubound(listarray)'############记录条数'[;c#H7hThQ
pagesize=2
c] kQ St*^ d1] pagecount=recordcount/pagesize '#######取得页面数
3t MS*n4u2O if instr(1,pagecount,".")=null or instr(1,pagecount,".")=0 then
J\JAbQe pagenum=pagecount
OJ{V}6f$|Te else
if%F0^e0?/G(s_ pagenum=int(pagecount) 1
xtNPf `[R end if2r I0K/C l d\i
:r;w%F8K3If'~XP
dim topage
b$D)J)w h?\3^i topage=cint(Request.QueryString ("topage")) '########取得要显示的页面
\^!`-HET if topage=0 then
5E'`4{?I"Z PB0F topage=1S8J(d'_A:m7C4Pt
end if
t/w1r#nnS4{&x*q:\ if topagepagenum then
!uH?vbfzN topage=pagenum
[B`Kr\u!C'^&qr"H end if
_H'W.L@B:E6[;LA [3[4xZe |*BM/H5J

2ao5~zpsB(Z*{ dim i,j,nd!i'd r3U6BQ~ \
b=listarray
a#i}7yD W A L@'p:? for i=0 to recordcount-1 '########把每一条记录组成一个数组
rbn3O ]J&S#y j=split(listarray(i),",")
bB?#N2MRj$d if ubound(j)=6 then1G`"[!v&a:D:A;ib
b(i)="SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'li/SPANspan style='font-size:10pt'a href='news_view.asp?id="  j(0)  "' target=blank"  j(1)  "(图)/a 点击:"  j(4)"次 最后发布时间:"j(5)"/span"T0T0q0E4A p
else:|x W+}Z ]/Y0_b k!K*E
b(i)="SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'li/SPANspan style='font-size:10pt'a href='news_view.asp?id="  j(0)  "' target=blank"  j(1)  "/a 点击:"  j(4)"次 最后发布时间:"j(5)"/span"
!n ~ {;oH}%q$x.St end if
Nc/?;X8t next
;|I {2{8h5yl1\2q4A
&Z1{a/y/~`^%_\W | '########把记录反排序存储在新的数组实现按时间反排序
L*_a&Y hD/A dim c(100)
d ys`$Jvsz0X1k n=0
@x7?Fm for i=recordcount to 0 step -1WN,E:I6Ru,}LO6AK
c(n)=b(i)edQ \!p z
n=n 1}-}8e3?_2n"R+J7y ?#S:E
next
.qq ~FF
'UM$| HA N-R@f
-o^/M,dY/fc#HF6SK dim currentrecord
B-n MfEL1]0\ currentrecord=pagesize*(topage-1) 1 '#########显示每一页\!K*jvf J ?,h?]
for k=1 to pagesize
.rFH @#Sd?"`$iL R if len(c(currentrecord))=0 then
(j4kHHX-JG exit forf2N { C8Q$j w/d_ L
end if
r,MG*})wqB Response.Write c(currentrecord)"br"/pl'|v]W
currentrecord=currentrecord 1
] |5p oB9n next
jCA-Lc c Response.Write "body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0"
Skybh2M6s+m for m=1 to pagenum (ll;pl.L d x
response.write "span style=font-size:10pta href=news_list.asp?topage="m""m"/a/span "
#E6m9WQ:Y!KG next
(c$q!qcA]4]LOY&z5t 9U#~)^6@|(X
end if  9v;}.t mLT

4h[J0_kux Q0E)] %
页: [1]
查看完整版本: 用文本 ASP打造新闻发布系统(三)新闻列表显示