# ASP Recordsets & Functions Confusion

**URL:** <https://forum.kirupa.com/t/asp-recordsets-functions-confusion/303440>\
**Category:** programming\
**Created:** [January 20, 2010, 12:08pm UTC](https://forum.kirupa.com/t/asp-recordsets-functions-confusion/303440 "2010-01-20T12:08:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thedaveyb](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@thedaveyb](https://forum.kirupa.com/u/thedaveyb)\
**Post date:** [January 20, 2010, 12:08pm UTC](https://forum.kirupa.com/t/asp-recordsets-functions-confusion/303440/1 "2010-01-20T12:08:43Z")

</div>

Hey guys, I have to admit to be being more PHP than ASP - although sods law am working on a project in ASP. Am finding I can take some of the principals across from PHP but theres just one point i am struggling with.

I have this function to loop through and check for banners in a database then display on the site.

```auto

<%
function getCurrentBanners()

        dim db
        
        Set db=Server.CreateObject("adodb.recordset")
        SQL = "SELECT * FROM website_banners"
        db.open SQL, tiebaConn
        
        current_banners = "<div id=""rotator""><ul>"
        
        count = 0
        
            if not(db.eof) then
                do while not db.eof 
                
                    if count <> 0 then
                        current_banners = current_banners & "<li>" & vbCrLf
                    else 
                        current_banners = current_banners & "<li class=""show"">" & vbCrLf
                    end if
    
                    current_banners = current_banners & "<img alt=""" & db("strBannerAlt") &""" src=""/banners/uploads/" & db("flBannerImage") &""">" & vbCrLf
    
                    current_banners = current_banners & "</li>" & vbCrLf
      
                db.movenext
                count = count +1
                Loop
            End If     
            
        current_banners = current_banners & "</ul></div>"
        
        db.close
            
        set db=nothing
                
        getCurrentBanners = current_banners
            
end function        
%>
        

```

which works BUT as soon as i try and add a link in (\<a href…) via an IF statement before hand to check it needs a link as per below.

```auto

if db("strLink") <> "" then
                    current_banners = current_banners & "<a href="""& db("strLink") &""">" & vbCrLf
 end if

 current_banners = current_banners & "<img alt=""" & db("strBannerAlt") &""" src=""/banners/uploads/" & db("flBannerImage") &""">" & vbCrLf
                    
if db("strLink") <> "" then
                    current_banners = current_banners & "</a>" & vbCrLf
 end if

```

i get the resulting code…

```auto

<li class="show">
<a href="website link"> ' does appear
<img alt="" src="[/banners/uploads/](http://www.kirupa.com/forum/view-source:http://webdev.west-cheshire.ac.uk/banners/uploads/)"> ' alt and source are both blank?
</a>
</li>

```
