Rotating Script

Discussion in 'PHP' started by asiong62, Mar 22, 2009.

  1. #1
    I need a script that rotate my html files, so every click go to difference html file (max 10 html files). Can guys help me?

    thanks

    asiong62
     
    asiong62, Mar 22, 2009 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    
    // First, build an array of html files
    $htmlfiles = array ('1.html', '2.html', '3.html', '4.html', '5.html' );
    
    // include one of them randomly
    include($htmlfiles[rand(0,(count($htmlfiles)-1))]);
    
    
    PHP:
    - ads2help
     
    ads2help, Mar 22, 2009 IP
  3. asiong62

    asiong62 Banned

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ad2help, i'm newbie and i confused about the script. I need compliete script, can you help me?

    thanks

    sindyjk
     
    asiong62, Mar 22, 2009 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    My scripts is complete.

    Create a php file called whatever.php and paste this inside
    <?php
    // First, build an array of html files
    $htmlfiles = array ('1.html', '2.html', '3.html', '4.html', '5.html' );
    
    // include one of them randomly
    include($htmlfiles[rand(0,(count($htmlfiles)-1))]);
    
    ?>
    PHP:
    Edit the 1.html , 2.html, etc.. to the name of your html files.

    Let your visitor visit yoursite.com/whatever.php and they will see random content everytime.

    That's all.
     
    ads2help, Mar 22, 2009 IP
  5. mfp

    mfp Guest

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    u can use this script

    <?php
    //entered urls are only examples
    $urls = array('http://www.examplesite.com/1.html',
    'http://www.examplesite.com/2.html',
    'http://www.examplesite.com/3.html',
    'http://www.examplesite.com/4.html',
    'http://www.examplesite.com/5.html');
    headers_sent() ? die('<a href="' . $urls[rand(0, count($urls)-1)] . '">Go</a>') : header('Location: ' . $urls[rand(0, count($urls)-1)]);
    ?>
    PHP:
     
    mfp, Mar 23, 2009 IP
  6. asiong62

    asiong62 Banned

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks guys.

    sindyjk
     
    asiong62, Mar 23, 2009 IP