When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs

















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Windows Systems Administrator
Jupitermedia
US-CT-Darien

Justtechjobs.com Post A Job | Post A Resume

Published: Tuesday, March 07, 2000

Loops within Loops: Coding an ASP-based Bulletin Board, Part 2
By Zola


  • Read Part 1

  • You will notice that there is a little extra code here, and that I explicitly closed the sql when the loop was done. This is because, although I am only showing one nested loop for this article, you will see in the full code that there are actually 12 loops nested in that original loop. What I found was that if one post had 3 responses and another only two, the second post would show the third response from the first post because there was an appropriately named variable still floating around out there. Once the nested loops have run, they need to be closed and set to nothing so when the set runs again we are starting fresh. If we traced the steps, they would go something like this:

      - continued -

      1.) Display the first main post
      2.) Display the first response to the first main post. If there are none, go to Step 5.
      3.) Display the second response to the first main post. If there are none, go to Step 5
      4.) Display the third response to the first main post (and so on-for this example we will end it here)
      5.) Display the second main post
      6.) Display the first response to the second main post. If there are none, go to Step 9.
      7.) Display the second response to the second main post. If there are none, go to Step 9
      8.) Display the third response to the second main post (and so on)
      9.) Display the third main post.....

    This neatly brings us to using that eof command right in the SQL . This is because there is no need to have the server run any of the other loops if there are no responses to the post being looked at. By explicitly saying if eof = false, my code will bypass the rest of the loops unless there is something there. Because I have added an if statement, I have to tell it what to do if eof was indeed True. In this case, end the if and close the loop, at which point it jumps to the previous loop. This also helps keep the code running quickly and eases the burden on the server.

    Once it runs through all the nested loops, it goes back to the original loop of main posts and the whole cycle begins anew.

    Why did I choose 12 as the number of steps possible? Because we are a talky bunch. :) Actually the real reason it because that is the point at where the title is about 3/4 of the way across the page, and most people will start a new thread. In the rare case that someone has more to say, it is a simple matter to go into the database and change the ResponseTo field to 0 so that the discussion could keep going.

    The thing I like most of all is the adaptability of the script. Right now, my most active bulletin board displays the last 60 days worth of posts. If we become more active and the page starts getting long, it is the work of two seconds to limit the display further. For a big site like ASP Messageboard, which receives in the neighborhood of 250 - 350 posts a day, I would probably limit the display to one or two days! I would also change the archive page so that it displayed according to a date requested rather than having several fixed archive pages. It depends on your needs-I like to keep things simple.

    And voila! My looks-just-like-a-cgi-script bulletin board is up and running! To see a couple examples of this code in action, visit: http://www.zolaweb.com/heart/heart.asp

    I look forward to feedback!

    Zola - zola@zolaweb.com

  • Read Part 1


    Attachments:

  • Download the full code and Access database in ZIP format

    Disclaimer: As with any code, there may be bugs. If you would like to report a bug, please send full details and a correction if at all possible so that we can pass the correction on to everyone.

    If you would prefer to use another type of database, you would create a table with the following fields:

    PostID - the Primary key , an autonumber field
    BBName
    BBEmail
    Subject
    Message
    ResponseTo
    BBHomepageName
    BBHomepageURL
    ImageURL
    BBDate
    BBTime

    Don't forget to change the date information and connection properties in accordance with your database.

    Happy Programming!


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES