Rotate Content Through my Site

Posted on 2005-03-31
Medium Priority
Last Modified: 2008-03-17
I have 9 articles that I would like to rotate through my site. Right now I'm calling the article using <? include("article/1.html") ?>

All the pages on my site use a common template.

Is there any way that I can have the articles rotate through my site once per day? I would like to have them equally distributed throughout the site as well.

Question by:timshank
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 32

Accepted Solution

Batalf earned 500 total points
ID: 13675770
For a single page, you could change

<? include("article/1.html") ?>


$no = date("d")%9+1;
<? include("article/$no.html") ?>

The value of $no will be different for each day.


Expert Comment

ID: 13677384
If you don't care how evenly distributed they are, you can use a simple random bit. IE, each article has a 1 in 9 chance of displaying on each page view.


include( "article" . mt_rand( 1, 9 ) . ".html" );


The mt_rand function takes a min and max and is "more random" than rand(). http://www.php.net/mt_rand


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question