A simple PHP script for rotatin(random) banner with url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spamofon
    Confirmed User
    • Jun 2003
    • 2999

    #1

    A simple PHP script for rotatin(random) banner with url

    anyone has anything like that

    just want to rotate different banners on page, anyone have any simple php script to do that?

    thanks
  • Vell
    So Fucking Banned
    • Sep 2003
    • 170

    #2
    phpadsnew - not 'simple' but the best there is

    Comment

    • Yug
      Confirmed User
      • Dec 2002
      • 218

      #3
      Originally posted by Vell
      phpadsnew - not 'simple' but the best there is
      YugSTAR.com
      The online cartoon about the adult internet industry

      Comment

      • spamofon
        Confirmed User
        • Jun 2003
        • 2999

        #4
        Originally posted by Vell
        phpadsnew - not 'simple' but the best there is

        where can i get that?

        Comment

        • spamofon
          Confirmed User
          • Jun 2003
          • 2999

          #5
          does that mean google it?

          Comment

          • azguy
            Confirmed User
            • Nov 2004
            • 5167

            #6
            Just create an array with the links and their banner filename, shuffle it, and use the first item.

            Comment

            • MrIzzz
              If u touch it, I will cum
              • Sep 2003
              • 22923

              #7
              i'm in the process of installing phpadsnew now and it fucking rocks. amazing features in there but it takes alot of tinkering


              WHO WANTS TO PLAY GRAB-ASS?

              Comment

              • HowlingWulf
                Confirmed User
                • Nov 2001
                • 1662

                #8
                Your subject says random, which is easier than incremental rotate, so here you go.

                <?php
                $ban = array();
                array_push($ban,"HTML CODE1");
                array_push($ban,"HTML CODE2");
                array_push($ban,"HTML CODE3");
                srand ((double)microtime()*1000000);
                $randomnum = rand(0, count($ban)-1);
                echo $ban[$randomnum];
                ?>
                WP Porn directory/review theme Maddos $35.

                webmaster AT howling-wulf.com

                Comment

                • eadweb
                  Confirmed User
                  • Aug 2002
                  • 196

                  #9
                  I create a files called banner1.php, banner2.php... etc. 1 for each banner spot and then call them with a php include statment.

                  <?php

                  srand((double)microtime()*1000000);
                  switch (rand (1,5)) {

                  case 1: ?>

                  <a href=http://www.YourSponsor.com/ target=_blank>
                  <img src=/banners/YourBanner.gif width=468 height=80 border=0 alt="Click Here!"></a>

                  <? break;
                  case 2: ?>

                  <a href="http://www.YourSponsor.com/" target="_blank">
                  <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br>
                  <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a>

                  <? break;
                  case 3: ?>

                  <a href=http://www.YourSponsor.com/ target=_blank>
                  <img src=/banners/YourBanner.gif width=468 height=80 border=0 alt="Click Here!"></a>

                  <? break;
                  case 4: ?>

                  <a href="http://www.YourSponsor.com/" target="_blank">
                  <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br>
                  <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a>

                  <? break;
                  case 5: ?>

                  <a href="http://www.YourSponsor.com/" target="_blank">
                  <img src="/banners/YourBanner.gif" width=468 height=60 border=0 alt="Click Here!"><br>
                  <font face="Arial,Helvetica" size="3">Visit The Webs Largest Sex Personals Site... Join For Free!</font></a>

                  <? break; } ?>
                  I don't need no stinking sig.

                  Comment

                  • Lycanthrope
                    Confirmed User
                    • Jan 2004
                    • 4517

                    #10
                    banners.php (include this)

                    <?
                    $delim = "\n";
                    $cryfile = "banners.txt";
                    $fp = fopen($cryfile, "r");
                    $contents = fread($fp, filesize($cryfile));
                    $cry_arr = explode($delim,$contents);
                    fclose($fp);
                    srand((double)microtime()*1000000);
                    $cry_index = (rand(1, sizeof($cry_arr)) - 1);
                    $herecry = $cry_arr[$cry_index];
                    echo $herecry;
                    ?>

                    banners.txt
                    <a href="url1.com"><img border="0" src="image1.gif"></a>
                    <a href="url2.com"><img border="0" src="image2.gif"></a>
                    <a href="url3.com"><img border="0" src="image3.gif"></a>
                    more here 1 per line

                    Comment

                    • rickholio
                      Confirmed User
                      • Jan 2004
                      • 1914

                      #11
                      Yikes... there's some helluva inefficient ways being proferred here. Just goes to show that there's 100 ways to do something on a computer I suppose.

                      Here's an alternative that allows you to attach a separate banner with a URL, simple maintenance by adjusting array elements. Easily adapted to keeping image/URL pairs in a database.
                      Code:
                      <?
                      // Change the banner/URL mappings as you so desire.
                      $b = array(
                        'banner1.jpg' => 'http://target.url1',
                        'banner2.jpg' => 'http://target.url2',
                        'banner3.jpg' => 'http://target.url3'
                      );
                      
                      // If you'd rather use mysql:
                      // $q = mysql_query("select img, url from whatever_table order by rand() limit 1");
                      // $r = mysql_fetch_assoc($q);
                      // $img = $r[img]; $url = $r[url];
                      
                      $img = array_rand($b);  // The easy way to pull a random element from an array ;)
                      $url = $b[$img];
                      print "<A HREF='$url'><IMG SRC='$img' BORDER=0></A>";
                      ?>
                      HTH. HAND.
                      Last edited by rickholio; 03-02-2005, 08:39 PM. Reason: PS: Your sig STILL kinda freaks me out.
                      ~

                      Comment

                      • Doc911
                        Confirmed User
                        • Feb 2004
                        • 3695

                        #12
                        I can write that script with a simple admin panel to add or remove the banners for 20 bucks icq me at 161480555


                        For PHP/MySQL scripts ICQ 161480555 or email [email protected]

                        Comment

                        Working...