Need Help with code - rotate or randomize -

Discussion in 'HTML & Website Design' started by riklmn, May 16, 2008.

  1. #1
    Hi
    I need a way to change a page on every refresh
    This is the code I have

    <div id="body">
    <?php include('1.php'); ?>
    <?php include('2.php'); ?>
    <?php include('3.php'); ?>
    <?php include('4.php'); ?>
    <?php include('5.php'); ?>
    </div>

    I need to either randomize or rotate the order of the php files on refresh, preferably rotate.

    so 1-2-3-4-5 refresh 2-3-4-5-1 and so on (or randomize)
    what's the best way to do it?
    Thanks
     
    riklmn, May 16, 2008 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well i'm no PHP expert but maybe you could use the rand function in some way?

    Maybe if you named the files in such a way..
    blah1.html
    blah2.html
    blah3.html
    blah4.html

    and then used the rand function in such a way, then you could use an include like:
    blah "the random number" .html

    However i'm a complete noob and wouldn't know how to generate the random number. There's probably an easier way to go about this.
     
    wd_2k6, May 16, 2008 IP