SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    griffith
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not showing newsletter section if db is empty

    I have a newsletter form with 8 article sections. The resulting newsletter displays the sections in a specific format. However, if the user only has 6 articles, how can I prevent section 7 and 8 from being dispalyed as blank sections?

  2. #2
    SitePoint Zealot Biffy's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you could show us the code you are using to display the newsletter as it would help us to give you an answer.

    There are ways of not showing recordsets, such as:

    Code:
    DB_CONNECTIONSTRING = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath("/db/database.mdb")
    Set objConn = Server.CreateObject("ADODB.Connection")
    objconn.open DB_CONNECTIONSTRING
    set objrs=Server.CreateObject("ADODB.Recordset")
    SQL="SELECT * FROM newsletter ORDER BY sectionid asc"
    set objrs=objconn.execute(SQL)
    
    if not objrs.BOF and not objrs.EOF then
    i=1 'set i to be a variable so we can use section numbers such as section1, section2 etc...
    do while not objrs.EOF
    
        if objrs("section"&i) <> ""  then 
         response.write ("section"&i) &"<br />" & vbcrlf
       end if 
    
    i=i+1
    objrs.movenext
    loop
    objrs.close
    end if 'bof and eof
    set objrs=nothing
    objconn.close : set objconn=nothing

    To be honest, unless you give us more detail on your specific problem then it's going to be hard to help.
    Sitenetics - Lending webmasters a helping hand


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •