Results 1 to 4 of 4
  1. #1

    Random HTML generator? Where? How?

    Hello-
    I want to put some banners on my forum (non-popup )and I want them to well, switch.....how do I do this? Thanks!!!!!

  2. #2
    would this work? Found it on another site... BTW, im using PHPbb to...if that matters.


    <script language="JavaScript">
    <!--



    <!--hide this script from non-javascript-enabled browsers

    /* Functions that swaps images. */

    /* Functions that handle preload. */

    // stop hiding -->//-->
    </script>

    <script language="JavaScript">
    <!--if (document.images)

    function changeImages()
    {
    if (document.images)
    {
    for (var i=0; i<changeImages.arguments.length; i+=2)
    { document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
    }
    }
    }
    // -->

    imglist=new Array()

    imglist[0] ="./splashimages/2002sep/01.jpg"
    imglist[1] ="./splashimages/2002sep/02.jpg"
    imglist[2] ="./splashimages/2002sep/03.jpg"
    imglist[3] ="./splashimages/2002sep/04.jpg"
    imglist[4] ="./splashimages/2002sep/05.jpg"
    imglist[5] ="./splashimages/2002sep/06.jpg"
    imglist[6] ="./splashimages/2002sep/07.jpg"
    imglist[7] ="./splashimages/2002sep/08.jpg"
    imglist[8] ="./splashimages/2002sep/09.jpg"
    imglist[9] ="./splashimages/2002sep/10.jpg"
    imglist[10] ="./splashimages/2002sep/11.jpg"
    imglist[11] ="./splashimages/2002sep/12.jpg"
    imglist[12] ="./splashimages/2002sep/13.jpg"
    imglist[13] ="./splashimages/2002sep/14.jpg"
    imglist[14] ="./splashimages/2002sep/15.jpg"
    imglist[15] ="./splashimages/2002sep/16.jpg"



    rndnum=Math.round(Math.random() * (15-0))+0
    img=imglist[rndnum]


    </script>

  3. #3

  4. #4
    Join Date
    Oct 2002
    Location
    Canada
    Posts
    3,100
    PHP/SQL

    This should display random banner. It could be extended to include description below banner, to display certain banners more often, to track number of clicks per banner, to handle jpeg and gif banners etc. It requires some admin interface that will let you upload and manage banners .

    page.html
    .....
    <? include 'banner.php' ?>
    .....

    banner.php
    <?php
    // make db connection

    if ($bannerId) {
    $res = @mysql_query ( "SELECT image from banners where id='$banner' LIMIT 1";
    $image = mysql_result($res,0);
    header ( "Content-type: image/gif");
    echo $image ;
    exit;
    }

    $res=mysql_query("select count (id) from banners where deleted <>'1' ") ;
    $rnd =rand(0, mysql_result ($res, 0) );
    $res = mysql_query ("select id , alt, link from banners LIMIT ( '$rnd' , 1) ) ;
    $bdata = mysql_fetch_array ($res) ;

    $html = '<a href="' .$bdata[link]. '"><img src="banner.php?bannerId=' . $bdata[id] . '" alt="' .$bdata[alt]. '"></a>';

    echo $html ;

    ?>


    banners table
    id , alt, link , deleted, image (BLOB)

Posting Permissions

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