Rotate Content Through my Site

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.

Thanks
timshankAsked:
Who is Participating?
 
BatalfConnect With a Mentor Commented:
For a single page, you could change

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

to

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

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

Batalf
0
 
lokipCommented:
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.

<?php

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

Regards,
Eric
0
All Courses

From novice to tech pro — start learning today.