Random Banner

Results 1 to 2 of 2

Thread: Random Banner

  1. #1
    Join Date
    Dec 1969

    Default Random Banner

    I am creating a new website with banners yet I need to make them random. I am pulling the banner location, target URL, and link text from a database. If someone could show me some code that would select one of the records from the database at random I would be very thankful.

  2. #2
    Join Date
    Dec 1969

    Default ASPFAQs, category Databases, Queries...

    The link to the ASPFAQs is at the top right corner of this very page. See the category noted above.<BR><BR>HOWEVER...<BR><BR>However, the right way to do this is probably *NOT* to use a DB request on each page.<BR><BR>After all, how many banners do you have to choose from? 100? 200? Even 1000?<BR><BR>So why not put them all into an array at Application_onStart time and then put the array into an Application variable (see the ASPFAQs, category Arrays).<BR><BR>Then when you need one you just pick it out of the array, which is dead simple:<BR><BR>&#060;%<BR>banners = Application("BannerAds")<BR>Randomize<BR>theBanner = banners( Int( RND * (UBound(banners)+1) )<BR>%&#062;<BR><BR>

Posting Permissions

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