Suggestions for a free PHP Rotation Script

6 replies
  • WEB DESIGN
  • |
Hi

I would like to know if anyone can suggest a php script that will allow me to rotare articles on my web page. For example I have 5 articles and I would like to show a different article to each new visitor on one page.

Thanks
#free #php #rotation #script #suggestions
  • Profile picture of the author jwlnewsome
    This is a quick one, normally the array is links for redirects
    <?php
    //array of the articles text or reference to them from a database
    $arr = array(
    'one','two','three','four','five')
    $rand = rand(0,4);
    $article = $arr[$rand];
    echo $article
    ?>

    if you want a proper script give me more details. ie where you store the articles. wont take long to knock one up
    {{ DiscussionBoard.errors[1350979].message }}
    • Profile picture of the author webmasteruk
      Thx jwlnewsome

      I have just been trying that code snippet and it does not work or atleast I cannot make it work.

      If there is a code snippet that can be put on web pages to allow random articles from one folder asigned to that web page to show all the articles in that folder randomly when a vistior visits.

      So each page will have its own folder filled with articles to be shown randomly on that page.
      {{ DiscussionBoard.errors[1351084].message }}
  • Profile picture of the author mywebwork
    Actually the code jwlnewsome posted is essentially what you need, perhaps you left off the closing semicolons on the array and echo lines like jwlnewsome did in their post. Essentially you're defining and array of articles and using a random number generator to make a selection in the array.

    Check your code for syntax errors and try again!

    Bill
    {{ DiscussionBoard.errors[1351222].message }}
  • Profile picture of the author da1fitz
    That was a nice bit of base code Bill - the only other option that I would have considered would be adding a dynamic database field that updates at pageload - plus a table containing the banner pics of course...
    {{ DiscussionBoard.errors[1351540].message }}
  • Profile picture of the author mywebwork
    Actually da1fitz the code was posted by jwlnewsome, I was just commenting on it.

    This link may be useful to the OP, there are several scripts to choose from here:

    PHP Random Text | Randomizing Scripts & Programs | Hot Scripts

    Bill
    {{ DiscussionBoard.errors[1351678].message }}
    • Profile picture of the author webmasteruk
      Thanks all for your help I have managed to get something working with the code that jwlnewsome posted. It took a little reasearch on google and a bit of cursing but it is now working the way I wanted it to work

      Again thans all for your help.
      {{ DiscussionBoard.errors[1354244].message }}

Trending Topics