首页 >> 技术文章 >> 详细内容
动网论坛首页调用方法

      动网论坛是我们已经很熟知的论坛程序了,目前发展最成熟也是最早的是ASP的动网论坛程序,我们就以ASP动网论坛为例,讲述如何做到首页调用!

      特别说明,下面的代码中,有的涉及到css,需要自己设计CSS样式。

      首先,想要用asp代码直接调用数据,那么你需要在你的首页最上面加上这三句代码:
      <!--#include file="conn.asp"-->
      <!--#include file="inc/const.asp"-->
      <!--#include file="inc/dv_clsother.asp"-->

      然后将我下面列出的代码,直接复制到你想调用的地方,也就是放到<td>和</td>之间。注意:<% %>不能少。

     下为调用代码:

首先是登陆:

<%
usergo()
sub usergo()
 response.write "<table align=left valign=baseline>"
 response.write "<tr><td  align=left >"
 If Dvbbs.UserID>0 Then
 'response.write "<tr><td align=center valign=middle>"
 'response.write "<img src="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text&" border=0 width="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text&" height="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text&"></td></tr><tr><td class=tablebody1 align=left>"登陆用户头像调用,如果需要请将前面的注释去掉。
 response.write "昵称: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@username").text&"&nbsp;&nbsp;"
 response.write "身份: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userclass").text&"&nbsp;&nbsp;"
 response.write "总贴: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpost").text&"&nbsp;&nbsp;"
 dim tempstr
 tempstr=split(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usertoday").text,"|")
 response.write "今日: "
 response.write ""&tempstr(0)&"&nbsp;&nbsp;" 
 response.write "财富: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text&"&nbsp;&nbsp;"
 response.write "金币: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text&"&nbsp;&nbsp;"
 response.write "经验: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userep").text&"&nbsp;&nbsp;"
 response.write "魅力: "
 response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usercp").text&"&nbsp;&nbsp;"
 'response.write "威&nbsp;&nbsp;&nbsp;&nbsp;望: "
 'response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userpower").text&"<br>" '威望
 'response.write "头衔: "
 'response.write ""&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usertitle").text&"<br>"
 response.write "<a href=hlogout.asp target=_self>安全退出</a>"
 else
 dim username,password
 response.write "<table width=""100%"" height=30 border=0 valign=top>"
 response.write "<form action=hlogin.asp?action=chk method=post name=loginform><tr><td align=center  height=""30"">"
 response.write "会员ID:<input maxLength=12 name=username size=11>&nbsp;&nbsp;"
 response.write "密&nbsp;码:<input maxLength=20 name=password size=11 type=password>&nbsp;&nbsp;" 
 if Dvbbs.forum_setting(79) =1 then
 Response.Write("&nbsp;&nbsp;")
 Response.Write("验 证 码:<input type=text name=codestr size=11><img src=DV_getcode.asp height=18 alt=验证码,看不清楚?请点击刷新验证码 style=""cursor : pointer;"" onclick=""this.src='DV_getcode.asp'"">")
 end if
 response.write "COOKIE:"
 response.write "<select name=CookieDate><option selected value=1>小存一天</option><option value=2>长存一月</option><option value=3>永久保存</option><option value=0>不想保存</option></select>&nbsp;<input type=button name=ok onclick=ok_() value=""登录"">&nbsp;<input onclick=""window.location.href='reg.asp'"" type=button  value=""注册"">&nbsp;<input onclick=""window.location.href='lostpass.asp'"" type=button  value=""忘记密码""></td></tr> </form>"
 response.write "</table>"
end if
 response.write "</table>"
end sub
%> 
<script>
function ok_(){
if(document.loginform.username.value=="" ){
alert("你还没写你的名字呢!^-^");
}else if( document.loginform.password.value==""){
alert("密码也要填写的!^-^");
}else{
document.loginform.submit();
}
}
</script>

说明:代码里面头像我默认注释掉了,想要显示头像的将前面的注释去掉就可以了。还有登陆后调用出来的信息是横的,如果需要竖着对齐,那么自己在相应的地方加换行符号(看代码里面的“威望”后面就有个<br>,自己照着加)。
同时,你还需要两个文件,一个hlogin.asp和hlogout.asp,在首页home.asp里面有这两个文件,将他传到论坛根目录下即可。

公告调用代码:
<%
bbsnews()
sub bbsnews()
 dim rs,sql,i,n,tlen
 n=6
 tlen=20
 sql="select top "&n&" boardid,title,username,addtime,id from [Dv_bbsnews] order by id desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
     else
 response.write "论坛目前没有公告"
 Exit sub
 end if
     rs.close:set rs=nothing

response.write "<MARQUEE behavior=scroll align=center direction=right height=25 scrollamount=1 scrolldelay=20 onmouseover='this.stop()' onmouseout='this.start()'>"

 for i=0 to Ubound(sql,2)
 response.write "∞&nbsp;"
 response.write "<a href=""announcements.asp?action=showone&boardid="& SQL(0,i) &"&id="&SQL(4,i)&""" target=""_blank"" title=""发表人:"&SQL(2,i)&"&nbsp;&nbsp;时间:"&SQL(3,i)&""">"
 response.write ""&left(sql(1,i),tlen)&""
 response.write "</a>"
 response.write "&nbsp;&nbsp;"
 next
response.write "</MARQUEE>"
 response.write "</td></tr>"
End sub
%>

默认是横向向右滚动,如果需要向上滚动,那请参照林肯的首页修改,direction=right,改为direction=up ;response.write ""&left(sql(1,i),tlen)&"" 改为response.write ""&left(sql(1,i),tlen)&"<br>"

会员信息调用:
<%
users()
function sexg(sexgb)
     Dim sqlgb
     Dim Rs
     if sexgb=1 then
     sqlgb="where Usersex=1"
     else
     sqlgb="where Usersex<>1"
     end if
     ConnectionDatabase
     set rs=conn.execute("Select count(*) from [dv_user]"&sqlgb)
     sexg=rs(0)
     set rs=nothing
end function
sub users()
 dim tnum,ynum,boynum,rs,sql,i
 tnum=0
 ynum=0
 BoyNum=sexg(1)
 sql="select JoinDate from [Dv_user] orders"
 Set Rs=DVbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
     end if
     rs.close:set rs=nothing
 For i=0 To Ubound(SQL,2)
  if FormatDateTime(SQL(0,i),vbShortDate)=FormatDateTime(date,vbShortDate) then
   tnum=tnum+1
  end if
  if FormatDateTime(SQL(0,i),vbShortDate)=FormatDateTime(DateAdd("d", -1, date()),vbShortDate) then
   ynum=ynum+1
  end if
 next
 response.write "<table cellspacing=1 cellpadding=5 class=mytableborder align=left>"
 response.write "<tr><td class=tablebody1>"
 Response.Write "<font face=Wingdings>J</font> 社区目前共有 <font color=#cc0000>"&Dvbbs.CacheData(10,0)&" </font>位会员<br>"
 Response.Write "<font face=Wingdings>J</font> 其中有 <font color=#cc0000>"&Dvbbs.CacheData(10,0)-BoyNum&" </font>名靓女<br><font face=Wingdings>J</font> 男士有 <font color=#cc0000>"&BoyNum&" </font>位<br>"
 Response.Write "<font face=Wingdings>J</font> 今天又来了 <font color=#cc0000>"&tnum&" </font>位新朋友<br>"
    Response.Write "<font face=Wingdings>J</font> 昨天好象来了 <font color=#cc0000>"&ynum&" </font>人<br>"
 Response.Write "<font face=Wingdings>J</font> 欢迎新人 <font color=#8b4513><b>"&Dvbbs.CacheData(14,0)&"</b></font> 的到来!<br>"
 response.write "</td></tr>"
 response.write "<tr><td></td></tr></table>"
end sub
%>
文字自己看着修改。

论坛信息调用:
<%
topic()
Function topic()
 response.write "<table cellspacing=1 cellpadding=5 class=mytableborder align=left>"
 response.write "<tr><td class=tablebody1>" 
 Response.Write "<font face=Wingdings>X</font> 今天已经有 <font color=#CC0000>"&Dvbbs.CacheData(9,0)&" </font>篇帖子了<br>"
 Response.Write "<font face=Wingdings>X</font> 昨天总共只有 <font color=#CC0000>"&Dvbbs.CacheData(11,0)&" </font>篇<br>"
 Response.Write "<font face=Wingdings>X</font> 社区共有 <font color=#CC0000>"&Dvbbs.CacheData(7,0)&" </font>篇主题<br>"
 Response.Write "<font face=Wingdings>X</font> 加上回帖一共有 <font color=#CC0000>"&Dvbbs.CacheData(8,0)&" </font>篇<br>"
 Response.Write "<font face=Wingdings>X</font> 最高的一天发了 <font color=#CC0000>"&Dvbbs.CacheData(12,0)&" </font>篇帖子<br>"
 Response.Write "<font face=Wingdings>X</font> 时间是:"&Dvbbs.CacheData(13,0)&"<br>"
 Response.Write "<font face=Wingdings>X</font> 曾经最高有 <font color=#CC0000>"&Dvbbs.Maxonline&" </font>人同时在线<br>"
 Response.Write "<font face=Wingdings>X</font> 好象是:"&Dvbbs.CacheData(6,0)&""
 response.write "</td></tr>"
 response.write "<tr><td></td></tr></table>"
end Function
%>
文字自己修改。

会员发贴排行:
<%
topuser()
sub topuser()
 dim rs,sql,i,n
 n=8
 sql="select top "&n&" userid,username,UserPost from [Dv_user] order by UserPost desc,userid desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
    end if
    rs.close:set rs=nothing
 response.write "<table cellspacing=1 cellpadding=5 align=center>"
 For i=0 To Ubound(SQL,2)
 response.write "<tr>"
 response.write "<td>"
 response.write ""&i+1&""
 response.write "</td>"
 response.write "<td>"
 response.write "<a href="
 Response.Write "dispuser.asp?id="
 Response.Write SQL(0,i)
 Response.Write " target=_blank title=查看"
 Response.Write Dvbbs.htmlencode(SQL(1,i))
 Response.Write "的个人资料>&nbsp;&nbsp;"
    response.write Dvbbs.htmlencode(SQL(1,i))
 response.write "</a>"
 response.write "</td>"
 response.write "<td>"
    response.write ""&Dvbbs.htmlencode(SQL(2,i))&""
 response.write "</td>"
 response.write "</tr>"
 response.write "</td></tr>"
 next
 response.write "</table>"
end sub
%>
“n=8”是调用个数,自己改。

最新贴子调用代码:
<%
mynewtopic()
sub mynewtopic()
 dim rs,sql,i,n,ds
 i=0
 n=8  '新贴调用个数
 sql="select top "&n&" a.topicid,a.title,a.boardid,a.postusername,a.lastpost,a.lastposttime,a.dateandtime,b.boardtype from dv_topic a,dv_board b where a.boardid<>444 and b.boardid=a.boardid order by dateandtime desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<table align=center>"
 response.write "<tr><td colspan=4 height=30 class=tablebody1 align=center valign=middle>目前没有新贴</td></tr>"
 response.write "</table>" 
 exit sub
     end if
     rs.close:set rs=nothing
 response.write "<table align=left valign=middle>"
 For i=0 To Ubound(SQL,2)
 response.write "<td class=tablebody1 align=left valign=middle><font face=Wingdings >w</font>&nbsp;"
 response.write "<a href=dispbbs.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(dvbbs.htmlencode(sql(1,i)),15)&""
 response.write "</a></td>"
 response.write "</td></tr>"
 next
 response.write "</table>" 
end sub
%>

精华调用:
<%
mybesttopic()
sub mybesttopic()
 dim rs,sql,i,n,myboard,ds,tempstr
 i=0
 n=10  '精华调用个数
 sql="select top "&n&" a.topicid,a.title,a.boardid,a.postusername,a.lastpost,a.lastposttime,a.dateandtime,b.boardtype from dv_topic a,dv_board b where a.boardid<>444 and b.boardid=a.boardid and a.isbest=1 order by dateandtime desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<tr><td>暂时还没有精华!</td></tr>"
 exit sub
     end if
     rs.close:set rs=nothing
 For i=0 To Ubound(SQL,2)
 tempstr=Split(sql(4,i),"$")
 myboard=sql(7,i)
 response.write "<font face=Wingdings>N</font>&nbsp;"
 response.write "<a href=dispbbs.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(sql(1,i),16)&"</a><br>" 
 next
end sub
%>

热门调用:
<%
HotTopic()
sub HotTopic()
 dim rs,sql,i,n,myboard,ds,tempstr
 i=0
 n=8  '热门贴调用个数
 sql="select top "&n&" a.topicid,a.title,a.boardid,a.postusername,a.lastpost,a.lastposttime,a.dateandtime,b.boardtype from dv_topic a,dv_board b where a.boardid<>444 and b.boardid=a.boardid order by Hits desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<table  align=center>"
 response.write "<tr><td colspan=4 height=30 class=tablebody1 align=center valign=middle>论坛目前没有新贴</td></tr>"
 response.write "</table>" 
 exit sub
     end if
     rs.close:set rs=nothing
 response.write "<table align=left>"
 For i=0 To Ubound(SQL,2)
 tempstr=Split(sql(4,i),"$")
 myboard=sql(7,i)
 response.write "<td align=left><font face=Wingdings>N</font>&nbsp;"
 response.write "<a href=dispbbs.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(dvbbs.htmlencode(sql(1,i)),16)&""
 response.write "</a></td>"
 response.write "</td></tr>"
 next
 response.write "</table>" 
end sub
%>

单个版块新贴调用:
<%
newtopic1()
sub newtopic1()
 dim rs,sql,i,n,ds
 i=0
 n=8  '新贴调用个数,情感论坛调用
 sql="select top "&n&" a.topicid,a.title,a.boardid,a.postusername,a.lastpost,a.lastposttime,a.dateandtime,b.boardtype from dv_topic a,dv_board b where a.boardid=19 and b.boardid=a.boardid order by dateandtime desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<table align=center>"
 response.write "<tr><td colspan=4 height=30 class=tablebody1 align=center valign=middle>目前没有新贴</td></tr>"
 response.write "</table>" 
 exit sub
     end if
     rs.close:set rs=nothing
 response.write "<table align=left valign=middle>"
 For i=0 To Ubound(SQL,2)
 response.write "<td class=tablebody1 align=left valign=middle><font face=Wingdings>W</font>&nbsp;"
 response.write "<a href=dispbbs.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(dvbbs.htmlencode(sql(1,i)),16)&""
 response.write "</a></td>"
 response.write "</td></tr>"
 next
 response.write "</table>" 
end sub
%>
说明:where a.boardid=19 19是版块ID,你想调用哪个版块就改成它的ID号。
重要说明:如果你分别调用多个版块,那么代码中的
newtopic1()
sub newtopic1()
不能一样,必须错开,可以改为其他,如:
newtopic2()
sub newtopic2()
或者
newtopic3()
sub newtopic3()
不然会出错,出什么错,自己试试就知道了。记得一定要修改!!
补充:如果你想要调用版块名称,或者发表人,时间等,那么你可以尝试修改代码
response.write ""&left(dvbbs.htmlencode(sql(1,i)),16)&""
中的“1”,数值从0-20分别对应着很多参数,自己有兴趣研究了。


发贴总冠军:
<%
allstar()
sub allstar()
 dim rs,sql,i,mysex,tempstr,mydate,tempface,face
 i=0
 sql="select top 1 userid,username,userpost,usersex,userface,userwidth,userheight,usertitle,joindate,lastlogin,userclass,usertoday from [dv_user] order by userpost desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
     end if
     rs.close:set rs=nothing
 tempface=split(sql(4,i),"|")
 If Ubound(tempface)>0 Then
 face=tempface(1)
 else
 face=tempface(0)
 end if
 if sql(3,i)=1 then
 mysex="Boy"
 else
 mysex="Girl"
 end if
 mydate=Split(sql(8,i),"")
 response.write "<table cellspacing=1 cellpadding=5 class=mytableborder align=center>"
 response.write "<tr><th align=center height=20>社区总冠</th></tr>"
 response.write "<tr><td class=tablebody1 align=center valign=middle>"
 response.write "<img src="&face&" border=0 height=75 width=75></td></tr>"
 response.write "<tr><td class=tablebody1 align=left>"
 response.write "昵称: "&sql(1,i)&"<br>"
 response.write "性别: "&mysex&"<br>"
 response.write "等级: "&sql(10,i)&"<br>"
 'response.write "头衔: "&sql(7,i)&"<br>"
 response.write "<font color= red>总贴:</font> "&sql(2,i)&"<br>"
 response.write "生日: "&mydate(0)&"<br>"
 'response.write "今日发贴: "&tempstr(0)&"<br>"
 response.write "</td></tr>"
 response.write "</table>" 
end sub     
 %>
 
 今日发贴冠军:
 <%
todaystar()
sub todaystar()
 dim rs,sql,i,mysex,tempstr,tempname,mydate,tempface,face
 i=0
 
 If IsSqlDataBase = 1 Then
 sql="select top 1 username,count(username) from "&Dvbbs.NowUseBBS&" where datediff(d,dateandtime,GetDate())<1 group by username order by count(username) desc"
 else
 sql="select top 1 username,count(username) from "&Dvbbs.NowUseBBS&" where DateAndTime>Date() group by username order by count(username) desc"
 end if
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
  tempname=rs(0)
  SQL=Rs.GetRows(-1)

 else
 response.write "<table cellspacing=1 cellpadding=5 class=mytableborder align=center>"
 response.write "<tr><th align=center height=20>今日冠军</th></tr>"
 response.write "<tr><td align=center class=tablebody1>新的一天开始了<br><br>目前还无人发贴<br><br>记录等你来改写</td></tr>"
 response.write "<tr><td width=""100%"" height=""24""></td></tr></table>" 
 exit sub
     end if
 
 sql="select top 2 userid,username,userpost,usersex,userface,userwidth,userheight,usertitle,joindate,lastlogin,userclass,usertoday from [dv_user] where username='"&tempname&"' order by userpost desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
 end if

     rs.close:set rs=nothing
  tempface=split(sql(4,i),"|")
 If Ubound(tempface)>0 Then
 face=tempface(1)
 else
 face=tempface(0)
 end if
 mydate=Split(sql(8,i)," ")
 if sql(3,i)=1 then
 mysex="Boy"
 else
 mysex="Girl"
 end if
 tempstr=Split(sql(11,i),"|")
 response.write "<table cellspacing=1 cellpadding=5 class=mytableborder align=center>"
 response.write "<tr><th align=certer height=20>今日冠军</th></tr>"
 response.write "<tr><td class=tablebody1 align=center valign=middle>"
 response.write "<img src="&face&" border=0 height=75 width=75></td></tr>"
 response.write "<tr><td class=tablebody1 align=left>"
 response.write "昵称: "&sql(1,i)&"<br>"
 response.write "性别: "&mysex&"<br>"
 response.write "等级: "&sql(10,i)&"<br>"
 'response.write "头衔: "&sql(7,i)&"<br>"
 response.write "<font color=red>今日:</font> "&tempstr(0)&"<br>"
 response.write "生日: "&mydate(0)&"<br>" 
 response.write "</td></tr>"
 response.write "</table>" 
end sub
%>

版块帖子数量排行:
<%
myboard()
sub myboard()
 dim rs,sql,i,n
 n=8  '板块排行调用个数
 i=0
 sql="select top "&n&"  boardid,boardtype,depth,postnum from [dv_board] where depth<>0 order by postnum desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<table cellspacing=1 cellpadding=5  align=center>"
 response.write "<tr><th align=left height=24 colspan=3 >热门版块排行</th></tr>"
 response.write "<tr><td class=tablebody1 colspan=3>论坛无板块</td></tr>"
 response.write "</table>"
 exit sub 
   
     end if
     rs.close:set rs=nothing
 response.write "<table cellspacing=1 cellpadding=5 align=center class=bankuai>"
 response.write "<tr><th align=center height=20 colspan=3 class=bankuai >热门版块排行</th></tr>"
 response.write "<tr><td align=center height=20 colspan=3 class=bankuai >板块名称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;帖子总数</td></tr>"
 For i=0 To Ubound(SQL,2)
 response.write "<tr>"
 response.write "<td class=bankuai>"
 response.write ""&i+1&""
 response.write "</td>"
 response.write "<td class=bankuai>"
 response.write "<a href=index.asp?boardid="&sql(0,i)&" target=""_blank"" title=""进入板块浏览"" class=bankuai>"
 response.write ""&sql(1,i)&""
 response.write "</a></td>"
 response.write "<td class=bankuai>"
 response.write ""&sql(3,i)&""
 response.write "</td></tr>"
 next
response.write "</table>" 
end sub
%>


投票贴调用:
<%
toupiao()
sub toupiao()
 dim rs,sql,i,n,ds,tempstr,votetotal
 i=0
 n=5  '投票调用个数
 sql="select top "&n&" * from Dv_topic where isvote=1 order by topicid desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
   response.write "<table height =110 align=left>"
    response.write "<tr><td width=300 align=center><b>社区最新投票</b></td><td width=90 align=center><b>发布人</b></td><td width=56 align=right><b>参与数</b></td></b></tr>"
 response.write "<tr><td colspan=4 height=30  align=center valign=middle>目前还没有人发布投票!</td></tr>"
 response.write "<tr><td></td></tr></table>" 
 exit sub
   end if
     rs.close:set rs=nothing
    response.write "<table height =110 align=left>"
    response.write "<tr><td width=300 align=center><b>社区最新投票</b></td><td width=90 align=center><b>发布人</b></td><td width=56 align=right><b>参与数</b></td></b></tr>"
 For i=0 To Ubound(SQL,2)
 tempstr=Split(sql(4,i),"$")
 response.write "<td align=left><img src=1234/toupiao.gif>&nbsp;&nbsp;"
 response.write "<a href=dispbbs.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(sql(1,i),22)&""
 response.write "</a></td><td  align=center width=""90"">"
 response.write "<a href="
 Response.Write "dispuser.asp?name="
    Response.Write  sql(6,i)
 Response.Write " target=_blank title=查看"
 response.write ""&sql(6,i)&""
 Response.Write "的个人资料>"
    response.write Dvbbs.htmlencode(SQL(6,i))
 response.write "</a>"
 response.write "<td width=56 align=right><font color=red><b>"&sql(11,i)&"</b></font> 票"
 response.write "</td></tr>"
 next
 response.write "</table>" 
end sub
%>

友情连接调用:
<%
Getmylink()
Function Getmylink()
 Dim Rs,sql
 Dim m,i,k
 m=0
 k=1
 sql="select boardname,readme,url,logo,islogo from [Dv_Bbslink] orders"
 Set Rs=DVbbs.Execute(sql)
 If Not RS.Eof then
   SQL=Rs.GetRows(-1)
      
      rs.close:set rs=nothing
  response.write "<table  align=left>"
  response.write "<tr><td >"
  For i=0 To Ubound(SQL,2)
   if SQL(4,i)=1 then
   response.write "<a href="&SQL(2,i)&" target=""_blank""><img src="&SQL(3,i)&" border=0 width=""88"" height=""31"" title="&SQL(1,i)&"></a>"
     response.write "&nbsp;"
   k=k+1
   if k Mod(9)=1 then
   response.write "<br>"
   end if
   end if

  next
  response.write "<br>"
  For i=0 To Ubound(SQL,2)
   if SQL(4,i)=0 then
   response.write "<a href="&SQL(2,i)&" target=""_blank"" title="&SQL(1,i)&">"&SQL(0,i)&"</a>"     
     response.write "&nbsp;&nbsp;"
   end if
  next
 else
  response.write "<table align=left>"
  response.write "<tr><td class=tablebody1>"
  response.write "当前没有友情链接"
 end if
 response.write "</td></tr>"
 response.write "</table>"
End Function
%>

当前在线:(好象不怎么准确)
<%
online()
sub online()
 Dim rs,sql,m,k,i
 m=0
 k=0
 sql="select username from [Dv_online] orders"
 Set Rs=DVbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
 else
  response.write "<table cellspacing=1 cellpadding=5 align=center>"
  response.write "<tr><td align=center>"
  Response.Write "目前无人在线"
  response.write "</td></tr>"
  response.write "</table>"
  exit sub
     end if
     rs.close:set rs=nothing
 For i=0 To Ubound(SQL,2)
  m=m+1
 next
 For i=0 To Ubound(SQL,2)
  if SQL(0,i)="客人" then
  k=k+1
  end if
 next
 response.write "<table cellspacing=1 cellpadding=5 align=left>"
 response.write "<tr><td >"
 Response.Write "当前总在线:" 
 Response.Write ""&m& "人<br>"
 Response.Write " 会员:"
 Response.Write ""&m-k&" 人 &nbsp;&nbsp;"
 Response.Write "访客:"
 Response.Write ""&k&" 人"
 response.write "</td></tr>"
 response.write "</table>"
end sub
%>

今日登陆会员名单统计:
<%
showtoday()
sub showtoday()
 dim u_num,sql,rs,i
 u_num=0
 response.write "<table align=left width=166 >"
 sql="select UserName,LastLogin from [Dv_User] order by lastlogin desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
  SQL=Rs.GetRows(-1)
 else
  response.write "</table>"
  exit sub
     end if
  rs.close:set rs=nothing
 response.write "<tr><td align=left width=166 >"
 for i=0 To Ubound(SQL,2)
  if FormatDateTime(sql(1,i),vbShortDate)=FormatDateTime(date,vbShortDate) then
  response.write "<a href=dispuser.asp?name="&sql(0,i)&" target=""_blank"" title=查看"&sql(0,i)&"的个人资料>"
  response.write ""&sql(0,i)&"</a>"
  response.write "&nbsp;"  
  end if
 next
 response.write "</td></tr>"
 response.write "</table>"
end sub
%>

博客调用:(前提是你的博客是和论坛是同一个数据库,如果是分开的,那么将出错。)
<%
boke()
sub boke()
 dim rs,sql,i,n,ds
 i=0
 n=8  '博客调用,博客调用个数
 sql="select top "&n&" TopicID,UserID,UserName,Title,LastPostTime From [Dv_Boke_Topic] where sType<>2 and IsLock<3 Order By TopicID desc"
 set rs=Dvbbs.Execute(sql)
 If Not RS.Eof then
 SQL=Rs.GetRows(-1)
 else
 response.write "<table align=center>"
 response.write "<tr><td colspan=4 height=30 class=tablebody1 align=center valign=middle>当前博客还没有文章</td></tr>"
 response.write "</table>" 
 exit sub
     end if
     rs.close:set rs=nothing
 response.write "<table align=left valign=middle>"
 For i=0 To Ubound(SQL,2)
 response.write "<td align=left  width=250 valign=middle><font face=Wingdings>l</font>&nbsp;"
 response.write "<a href=boke.asp?boardid="&sql(2,i)&"&id="&sql(0,i)&" target=""_blank"">"
 response.write ""&left(dvbbs.htmlencode(sql(3,i)),18)&""
 response.write "</a></td>"
 response.write "<td align=center width=94 valign=middle>"
 response.write "<a href="
 Response.Write "dispuser.asp?name="
 Response.Write SQL(2,i)
 Response.Write " target=_blank title=查看"
 Response.Write Dvbbs.htmlencode(SQL(2,i))
 Response.Write "的个人资料>"
 Response.Write "["
    response.write Dvbbs.htmlencode(SQL(2,i))
 response.write "]</a>"
 response.write "</td>"
 response.write "</td></tr>"
 next
 response.write "</table>" 
end sub
%>

至此真个首页的调用就做完成了,当然要想做一个绚丽的首页,必须需要CSS样式的支持!

南京服务器托管 | 南京企业建站 | 南京网站建设 | 南京网站优化 | 南京中绘谷网络技术有限公司 | 467.cn
| 整理发布 | TEL:13913852884,025-58633651,QQ:21390019

发布者:admin 发布时间:2010/7/16 阅读:4995

Baidu
Copyright © 2002-2021 467.Cn All rights reserved    南京华昊网络技术有限公司    版权所有
备案序号:苏ICP备13052121号    ISP经营许可证:苏B2-20080166    ICP/SP经营许可证:苏B2-20130350      苏公网安备 32011102010099号
地址:南京市江北新区大桥北路77号电信大楼5楼    电话:025-58633651(8线)  13913852884  传真:025-58497310    E-mail:467cn@163.com    邮编:210032
网址:Www.467.Cn    QQ在线支持:点击这里给我发消息 点击这里给我发消息