asp:首页新闻调用

<!--#include file="inc/conn.asp"-->
<%
'*********************************************************************************************
'文件名: newstopic.asp 首页新闻调用
'可以重复调用,调用方式<script src=newstopic.asp?info=1&tlen=13&newstype=1&n=8&orders=1></script>
'其中info为显示日期 1显示0不显示
'tlen为显示标题长度
'newstype为新闻类型 1新闻中心 2广告中心 3展交中心
'n为显示多少记录,如果为空,则取默认值10
'orders为排序方式 1为按点击率排序 0为按日期排序
'powered by 清风
'MSN: anwellsz@msn.com
'QQ: 110125707
'Last Update: 11/15/2004
'**********************************************************************************************


Rem 过滤HTML代码
function HTMLEncode(fString)
if not isnull(fString) then
    fString = replace(fString, ">", "&gt;")
    fString = replace(fString, "<", "&lt;")

    fString = Replace(fString, CHR(32), "&nbsp;")
    fString = Replace(fString, CHR(9), "&nbsp;")
    fString = Replace(fString, CHR(34), "&quot;")
    fString = Replace(fString, CHR(39), "&#39;")
    fString = Replace(fString, CHR(13), "")
    fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
    fString = Replace(fString, CHR(10), "<BR> ")

    HTMLEncode = fString
end if
end function

dim rs,topic,rss,newstype,newsurl,n,orders
newstype = Request("newstype")
n = Request("n")
if isnumeric(n)=0 or n="" then n=10
if request("orders")=1 then
 orders="hits"
else
 orders="tDate"
end if

select case newstype
 case 1
  newstype = "新闻中心"
  newsurl = "two-1.asp"   '新闻链接地址,请根据相应页面做适当修改
 case 2
  newstype = "广告中心"
  newsurl = "three-1.asp"
 case 3
  newstype = "展交中心"
  newsurl = "four-a1.asp"
 case else
end select

set rss=conn.execute("select id,classname from [classname] where classname='"&newstype&"'")
do while not rss.eof
  newstypeid = rss(0)
  rss.movenext
loop
set rs=conn.execute("select top "&n&" id,Title,classid,tDate,hits from news where classid = "&newstypeid&" ORDER BY "&orders&" desc")
do while Not RS.Eof
 topic = rs(1)
 if len(topic)>Cint(request("tlen")) then
  topic=left(topic,request("tlen"))&"..."
    end if
 topic=HTMLEncode(topic)

 response.write "document.write('<tr><td width=5% height=22><p align=left><img src=images/14.gif></td><td height=22 width=68% ><span style=""font-size:9pt;line-height: 15pt""><a href="&newsurl&"?newsid="&rs(0)&" target=_blank><font color=#000000>');"
        response.write "document.write('"&topic&"');"
 response.write "document.write('</font></a></td>');"
 select case request("info")
 case 1
 response.write "document.write('<td><font color=#808080>"&year(rs(3))&"-"&month(rs(3))&"-"&day(rs(3))&"</font></td></tr>');"
 case else
 response.write "document.write('<Td>&nbsp</td></tr>');"
 end select

 response.write "document.write('</span>');"
 RS.MoveNext
Loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值