asp编程问题(控制网页友情链接数目) 10
以下代码是asp语言在网页中控制友情链接显示数目的,现在只能显示4个,怎么修改能显示4个以上的连接呢?<%FunctionFriendLinks(trs,tds)dimr...
以下代码是asp语言在网页中控制友情链接显示数目的,现在只能显示4个,怎么修改能显示4个以上的连接呢?
<%Function FriendLinks(trs,tds)
dim rs,sql,tr,td,ProductName,SmallPicPath
set rs = server.createobject("adodb.recordset")
sql="select top "&trs*tds&" * from Qianbo_FriendLink where ViewFlag order by ID desc"
rs.open sql,conn,1,1
if rs.eof then
response.write "暂无相关信息"
else
Response.Write "<table cellpadding=""0"" cellspacing=""0"" align=""center"">"&VbCrLf
for tr=1 to trs
Response.Write " <tr>"&VbCrLf
for td=1 to tds
if StrLen(rs("LinkFace"))<=18 then
LinkFace=rs("LinkFace")
else
LinkFace=StrLeft(rs("LinkFace"),16)
end if
Response.Write " <td><table cellpadding=""2"" cellspacing=""0"">"&VbCrLf
Response.Write " <tr>"&VbCrLf
Response.Write " <td align=""center"" height=""38"">"
If rs("LinkType") = 0 Then
Response.Write "<a href="""&rs("LinkUrl")&""" title="""&rs("LinkName")&""">"&LinkFace&"</a>"
Else
Response.Write "<a href="""&rs("LinkUrl")&""" target=""_blank""><img src="""&rs("LinkFace")&""" alt="""&rs("LinkName")&""" width=""88"" height=""31"" border=""0"" /></a>"
End If
Response.Write "</td>"&VbCrLf
Response.Write " </tr>"&VbCrLf
Response.Write " </table></td>"&VbCrLf
Response.Write " <td width=""8""></td>"&VbCrLf
rs.movenext
if rs.eof then exit for
next
Response.Write " </tr>"&VbCrLf
if rs.eof then exit for
next
Response.Write "</table>"&VbCrLf
end if
rs.close
set rs=nothing
End Function
%> 展开
<%Function FriendLinks(trs,tds)
dim rs,sql,tr,td,ProductName,SmallPicPath
set rs = server.createobject("adodb.recordset")
sql="select top "&trs*tds&" * from Qianbo_FriendLink where ViewFlag order by ID desc"
rs.open sql,conn,1,1
if rs.eof then
response.write "暂无相关信息"
else
Response.Write "<table cellpadding=""0"" cellspacing=""0"" align=""center"">"&VbCrLf
for tr=1 to trs
Response.Write " <tr>"&VbCrLf
for td=1 to tds
if StrLen(rs("LinkFace"))<=18 then
LinkFace=rs("LinkFace")
else
LinkFace=StrLeft(rs("LinkFace"),16)
end if
Response.Write " <td><table cellpadding=""2"" cellspacing=""0"">"&VbCrLf
Response.Write " <tr>"&VbCrLf
Response.Write " <td align=""center"" height=""38"">"
If rs("LinkType") = 0 Then
Response.Write "<a href="""&rs("LinkUrl")&""" title="""&rs("LinkName")&""">"&LinkFace&"</a>"
Else
Response.Write "<a href="""&rs("LinkUrl")&""" target=""_blank""><img src="""&rs("LinkFace")&""" alt="""&rs("LinkName")&""" width=""88"" height=""31"" border=""0"" /></a>"
End If
Response.Write "</td>"&VbCrLf
Response.Write " </tr>"&VbCrLf
Response.Write " </table></td>"&VbCrLf
Response.Write " <td width=""8""></td>"&VbCrLf
rs.movenext
if rs.eof then exit for
next
Response.Write " </tr>"&VbCrLf
if rs.eof then exit for
next
Response.Write "</table>"&VbCrLf
end if
rs.close
set rs=nothing
End Function
%> 展开
展开全部
控制记录数是通过这条SQL语句实现的
sql="select top "&trs*tds&" * from Qianbo_FriendLink where ViewFlag order by ID desc"
top后面需要一个数字,或一个百分数,像你这种情况需要一个整数,即trs*tds
而这两个变量在调用时确定,并且根据程序可以知道tds是友情链接每行显示的数目
要达到你的要求,你在调用函数FriendLinks(trs,tds)的地方设置两个参数就行了。比如FriendLinks(2,2),那取得的记录数为4,如果是FriendLinks(3,2),那显示的数目为6个,分两列三行显示。
但前提是你的数据库中要有4个以上的记录
sql="select top "&trs*tds&" * from Qianbo_FriendLink where ViewFlag order by ID desc"
top后面需要一个数字,或一个百分数,像你这种情况需要一个整数,即trs*tds
而这两个变量在调用时确定,并且根据程序可以知道tds是友情链接每行显示的数目
要达到你的要求,你在调用函数FriendLinks(trs,tds)的地方设置两个参数就行了。比如FriendLinks(2,2),那取得的记录数为4,如果是FriendLinks(3,2),那显示的数目为6个,分两列三行显示。
但前提是你的数据库中要有4个以上的记录
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询