(三)把新聞代碼插入你的頁面 最好的新聞發布,當然是為網站本身定做的,那樣才能與主頁風格一致,但如此一來,新聞發布系統有缺乏了通用性了,不能移值到別的網站上使用,有得必有失,在這個基礎上關鍵是找一個平行點。綜合來考濾,最好的做法是與頁面分離,那樣就可以不影響網頁的外觀,而也能達到很好的效果,在使用新聞的網頁上我們可以通過放置一條這樣的script語句來調用新聞代碼 《script language="javaScript" src="http//xxx.com.cn/special/linux/lnews/autoup.asp"》 大家可以到這里看看效果 現在請大家看看autoup.asp的代碼。 《% @language="vbscript" %》 《!--#include Virtual="/news/data/data.inc"--》 《% Set rs = Server.CreateObject("ADODB.Recordset") sql="select * from data Order by news_id Desc" rs.open sql,conn,3,2 if rs.bof then response.end end if
disp=disp&"《tr》《td width=100% 》《a href=http://www.aaaaa.com.cn/news/read.asp?news_id="&rs("news_id")&" target=_blank》>>"&rs("news_title")&"《/a》(《font size=1》"&rs("news_year")&"-"&rs("news_month")&"-"&rs("news_day")&" "&rs("news_time")&"《/font》)《/td》《/tr》" if count》=10 then 'clng(application("disp_1"))-1 then exit do end if count=count+1
disp=disp&"《tr》《td width=100% 》《a href=http://www.aaaaa.com.cn/news/read.asp?news_id="&rs("news_id")&" target=_blank》>>"&rs("news_title")&"《/a》(《font size=1》"&rs("news_year")&"-"&rs("news_month")&"-"&rs("news_day")&" "&rs("news_time")&"《/font》)《/td》《/tr》" if count》=10 then 'clng(application("disp_2"))-1 then exit do end if count=count+1
do while not rs.eof 'IT新聞 if Cint(rs("news_class"))=2 then
disp=disp&"《tr》《td width=100% 》《a href=http://www.aaaaa.com.cn/news/read.asp?news_id="&rs("news_id")&" target=_blank》>>"&rs("news_title")&"《/a》(《font size=1》"&rs("news_year")&"-"&rs("news_month")&"-"&rs("news_day")&" "&rs("news_time")&"《/font》)《/td》《/tr》" if count》=50 then 'clng(application("disp_3"))-1 then exit do end if count=count+1
end if rs.movenext loop disp=disp&"《tr》《td width=100% align=right》【更多新聞...】 《/td》《/tr》" dispmess=dispmess&disp
《% @language="vbscript" %》 《!--#include Virtual="/news/data/data.inc"--》 《% Set rs = Server.CreateObject("ADODB.Recordset") sql="select * from data where Cstr(news_id)='"&Cstr(request.querystring("news_id"))&"'" rs.open sql,conn,3,2 %》 《html》