很多朋友都在問風訊中如何調用一些比較個性的東西,因為是靜態的頁面,沒辦法直接執行asp
所以今天我抽空寫了一個簡單的例子,有愛好的朋友可以看一下。希望會對大家有所幫助。
這個例子的功能是可以在首頁調用網站注冊的會員資料。
在風訊根目錄下新建一asp文件:member,asp,文件代碼如下:
<!--#include file="Inc/Cls_DB.asp" -->
<!--#include file="Inc/Const.asp" -->
<!--#include file="Inc/Function.asp" -->(插入風訊的常量設置文件,如數據庫路徑和連接都在這幾個文件里)
<%
'*******************code by chenwfy***********2006-04-25*********************************
'功能說明:調用最新會員資料
'************************************************************************************************
(注釋)
Set DBC = New DataBaseClass
Set Conn = DBC.OpenConnection()
Set DBC = Nothing
(建立數據庫連接,好象是吧,不大懂,嘿嘿。)
'==========================================================================
'設置調用會員數量
dim Getnum
Getnum = 10
'==========================================================================
(定義一個變量,設置調用會員資料的數量)
dim tempobj,tempsql
tempsql = "select top "& Getnum &" id,MemName,***,loginnum from FS_Members order by id desc"
set tempobj = conn.execute(tempsql)
(查詢數據庫,取得對應的資料)
if not tempobj.eof then
do while not tempobj.eof
dim memid,memname,mem***,true***,memloginnum
memid = tempobj("id")
memname = tempobj("memname")
mem*** = tempobj("***")
memloginnum = tempobj("loginnum")
if mem*** = "0" then
true*** = "<font color=""red"">女</font>"
else
true*** = "<font color=""bule"">男<font>"
end if
(重點在下面這里,呵呵,輸出document.write后的內容并循環,這樣才可以用js調用)
Response.write "document.write('<table width=""220"" border=""0"" cellpadding=""0"" cellspacing=""0"">"&"<tr>"&"<td width=""120"" height=""20"" align=""center"" valign=""middle"">"&"<a href=memtext.asp?id="& memid &" title=""點擊查看此會員的具體資料"" target=""_blank"">"& memname &"</a>"&"</td>"&"<td width=""50"" height=""20"" align=""center"" valign=""middle"">"& true*** &"</td>"&"<td width=""50"" height=""20"" align=""center"" valign=""middle"">"& memloginnum &"</td>"&"</tr>"&"</table>');"
tempobj.movenext
loop
else
response.Write"暫時還沒有會員哦"
end if
tempobj.close
set tempobj = nothing
set conn = nothing (關閉數據庫連接)
%>
新聞熱點
疑難解答