欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

<%
    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,"|") #######把所有记录分割成一个数组a
     

     dim recordcount,pagecount, pagesize, pagenum
     recordcount=ubound(listarray)############记录条数
      pagesize=2
     pagecount=recordcount/pagesize  #######取得页面数
     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 ########把每一条记录组成一个数组
       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)&"次 最后发布时间:"&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)&"次 最后发布时间:"&j(5)&"</span>"
       end if
   next
     
        ########把记录反排序存储在新的数组实现按时间反排序
   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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用文本+ASP打造新闻发布系统(三)新闻列表显示
分享到: 更多 (0)

相关推荐

  • 暂无文章