回 帖 发 新 帖 刷新版面

主题:[讨论]大家帮忙看看,每添加一个友情链接,都是往上跑的,我想让它横向怎么改呀

'==================================================
'过程名:ShowFriendLinks
'作  用:显示友情链接站点
'参  数:LinkType  ----链接方式,1为LOGO链接,2为文字链接
'       SiteNum   ----最多显示多少个站点
'       Cols      ----分几列显示
'       ShowType  ----显示方式。1为向上滚动,2为横向列表,3为下拉列表框
'==================================================
sub ShowFriendLinks(LinkType,SiteNum,Cols,ShowType)
    dim sqlLink,rsLink,SiteCount,i,strLink
    if LinkType<>1 and LinkType<>2 then
        LinkType=1
    else
        LinkType=Cint(LinkType)
    end if
    if SiteNum<=0 or SiteNum>100 then
        SiteNum=10
    end if
    if Cols<=0 or Cols>20 then
        Cols=10
    end if
    if ShowType=1 then'
        strLink=strLink & "<div id=rolllink style=overflow:hidden;height:100;width:100><div id=rolllink1>"    '新增加的代码
    elseif ShowType=3 then
        strLink=strLink & "<select name='FriendSite' onchange=""if(this.options[this.selectedIndex].value!=''){window.open(this.options[this.selectedIndex].value,'_blank');}""><option value=''>友情文字链接站点</option>"
    end if
    if ShowType=1 or ShowType=2 then
        strLink=strLink & "<table width='100%' cellSpacing='5'><tr align='center' >"
    end if
    
    sqlLink="select top " & SiteNum & " * from FriendLinks where IsOK=True and LinkType=" & LinkType & " order by IsGood,id desc"
    set rsLink=server.createobject("adodb.recordset")
    rsLink.open sqlLink,conn,1,1
    if rsLink.bof and rsLink.eof then
        if ShowType=1 or ShowType=2 then
              for i=1 to SiteNum
                strLink=strLink & "<td>"            
                strLink=strLink & "</td>"
                if i mod Cols=0 and i<SiteNum then
                    strLink=strLink & "</tr><tr align='center' >"
                end if
            next
        end if
    else
        SiteCount=rsLink.recordcount
        for i=1 to SiteCount
            if ShowType=1 or ShowType=2 then
              if LinkType=1 then
                strLink=strLink & "<td width='88'><a href='" & rsLink("SiteUrl") & "' target='_blank' title='网站名称:" & rsLink("SiteName") & vbcrlf & "网站地址:" & rsLink("SiteUrl") & vbcrlf & "网站简介:" & rsLink("SiteIntro") & "'>"
                if rsLink("LogoUrl")="" or rsLink("LogoUrl")="http://" then
                    strLink=strLink & "<img src='images/nologo.gif' width='88' height='31' border='0'>"
                else
                    strLink=strLink & "<img src='" & rsLink("LogoUrl") & "' width='88' height='31' border='0'>"
                end if
                strLink=strLink & "</a></td>"
              else
                strLink=strLink & "<td width='88'><a href='" & rsLink("SiteUrl") & "' target='_blank' title='网站名称:" & rsLink("SiteName") & vbcrlf & "网站地址:" & rsLink("SiteUrl") & vbcrlf & "网站简介:" & rsLink("SiteIntro") & "'>" & rsLink("SiteName") & "</a></td>"
              end if
              if i mod Cols=0 and i<SiteNum then
                strLink=strLink & "</tr><tr align='center' >"
              end if
            else
                strLink=strLink & "<option value='" & rsLink("SiteUrl") & "'>" & rsLink("SiteName") & "</option>"
            end if
            rsLink.moveNext
        next
        if SiteCount<SiteNum and (ShowType=1 or ShowType=2) then
            for i=SiteCount+1 to SiteNum
                if LinkType=1 then
                    strLink=strLink & "<td width='88'></td>"
                else
                    strLink=strLink & "<td width='88'></td>"
                end if
                if i mod Cols=0 and i<SiteNum then
                    strLink=strLink & "</tr><tr align='center' >"
                end if
            next
        end if
    end if
    if ShowType=1 or ShowType=2 then
        strLink=strLink & "</tr></table>"
    end if
    if ShowType=1 then
        strLink=strLink & "</div><div id=rolllink2></div></div>"   '新增代码
    elseif ShowType=3 then
        strLink=strLink & "</select>"
    end if
    response.write strLink
    if ShowType=1 then call RollFriendLinks()    '新增代码
    rsLink.close
    set rsLink=nothing
end sub

'==================================================
'过程名:RollFriendLinks
'作  用:滚动显示友情链接站点
'参  数:无
'==================================================


调用的语句:<%sqlLink="select top 10 * from FriendLinks where IsOK=True and LinkType=2 order by IsGood,id desc"
    set rsLink=server.createobject("adodb.recordset")
    rsLink.open sqlLink,conn,1,1
    do while not rsLink.eof%>
                    <tr> 
                     <td><a href='<%=rsLink("SiteUrl")%>' class='txt_ui01' target='_top'><%=rslink("sitename")%></a></td>
                    </tr>
                    <%rslink.movenext
                        loop
                        rslink.close
                        rslink=nothing%>
<%sqlLink="select top 10 * from FriendLinks where IsOK=True and LinkType=1 order by IsGood,id desc"
    set rsLink=server.createobject("adodb.recordset")
    rsLink.open sqlLink,conn,1,1
    do while not rsLink.eof%>
           
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><a href='<%=rsLink("SiteUrl")%>' target='_top'><img SRC='<%=rsLink("LogoUrl")%>'></a></td>
  </tr>
</table>

            <%rslink.movenext
loop
rslink.close
rslink=nothing%>

回复列表 (共5个回复)

沙发

请各位高手路过,帮小弟解决此问题,小弟在此谢过了

板凳

[color=FF0000]do while not rsLink.eof%>[/color]
                    <tr> 
                     <td><a href='<%=rsLink("SiteUrl")%>' class='txt_ui01' target='_top'><%=rslink("sitename")%></a></td>
                    </tr>
                       [color=008080][color=0000FF]<%rslink.movenext
                        loop
                        rslink.close
                        rslink=nothing%>[/color][/color]改为:

                    <tr> 
                     [color=0000FF]<%do while not rsLink.eof%>[/color]
                     <td><a href='<%=rsLink("SiteUrl")%>' class='txt_ui01' target='_top'><%=rslink("sitename")%></a></td>
                     [color=0000FF]<%rslink.movenext
                       loop
                       rslink.close
                       rslink=nothing%>[/color]
                    </tr>
           
[color=0000FF]循环<td>...</td>,即为横向 循环<tr>...</tr>即为竖向[/color]

3 楼

帅哥我按你的方法改,现在文字是可以横向了,但是排列的非常的不整齐,logo链接还是竖向的。请再次帮帮忙谢谢了

4 楼



在图片显示的地方用同样的方法(循环<td>...</td>)来循环即可,就像循环文字一

样!

5 楼

不行哦,我试过了,就是文字可以横向,LOGO就是不行,虽然文字现在是打横的,但排列非常的不整齐。请再次帮我想想办法呀,谢谢了

我来回复

您尚未登录,请登录后再回复。点此登录或注册