明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

用文本+ASP打造新聞公布系統(tǒng)(3)新聞下文顯示

[摘要]<% dim myfso,myreadset myfso=createobject("scripting.filesystemobject")set myread=myfs...
<%
dim myfso,myread
set myfso=createobject("scripting.filesystemobject")
set myread=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)

if myread.atendofstream then
Response.Write "目前沒有添加新聞"
Response.End
else

dim mytext,listarray
mytext=myread.readall
listarray=split(mytext," ") '#######把所有記錄分割成一個數(shù)組a

dim recordcount,pagecount, pagesize, pagenum
recordcount=ubound(listarray)'############記錄條數(shù)
pagesize=2
pagecount=recordcount/pagesize '#######取得頁面數(shù)
if instr(1,pagecount,".")=null or instr(1,pagecount,".")=0 then
pagenum=pagecount
else
pagenum=int(pagecount)+1
end if

dim topage
topage=cint(Request.QueryString ("topage")) '########取得要顯示的頁面
if topage<=0 then
topage=1
end if
if topage>pagenum then
topage=pagenum
end if


dim i,j,n
b=listarray
for i=0 to recordcount-1 '########把每一條記錄組成一個數(shù)組
j=split(listarray(i),",")
if ubound(j)=6 then
b(i)="<SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'><li></SPAN><span style='font-size:10pt'><a href='news_view.asp?id=" & j(0) & "' target=blank>" & j(1) & "(圖)</a> 點擊:" & j(4)&"次 最后發(fā)布時間:"&j(5)&"</span>"
else
b(i)="<SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'><li></SPAN><span style='font-size:10pt'><a href='news_view.asp?id=" & j(0) & "' target=blank>" & j(1) & "</a> 點擊:" & j(4)&"次 最后發(fā)布時間:"&j(5)&"</span>"
end if
next

'########把記錄反排序存儲在新的數(shù)組實現(xiàn)按時間反排序
dim c(100)
n=0
for i=recordcount to 0 step -1
c(n)=b(i)
n=n+1
next


dim currentrecord
currentrecord=pagesize*(topage-1)+1 '#########顯示每一頁
for k=1 to pagesize
if len(c(currentrecord))=0 then
exit for
end if
Response.Write c(currentrecord)&"<br>"
currentrecord=currentrecord+1
next
Response.Write "<body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0>"
for m=1 to pagenum
response.write "<span style=font-size:10pt><a href=news_list.asp?topage="&m&">"&m&"</a></span> "
next

end if

%>