Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display different html based on week

Status
Not open for further replies.

cydud3

IS-IT--Management
Dec 21, 2004
57
0
0
KE
I have 4 different html files that I need to display on my website as the index page. I want to cycle through them one each week. So, for this week, from Sunday to Saturday, anybody visiting will see homepage1.html. The next week, they will see homepage2.html...and so on. After the fourth week, it cycles back to homepage1.html.

I figure there must be a way of doing this on PHP. Can somebody please enlighten me. If not, maybe Javascript.

Thanks.

2B||!2B
 
something like this might work quite nicely. this code would be the entirety of the index.php (or site default page). all links from your hompages should point to the index.php page, ideally, to keep consistency.

Note: that this is not a great way to use switch. it's not intended to work like this but in this case it is somewhat neater than cascaded IF's
Code:
$day = (int) date ("j"); //get current day of month and cast to an integer
switch (TRUE){
 case ($day <= 7):
    $hp = 1; 
    break;
 case ($day <= 14):
    $hp = 2;
    break;
 case ($day <= 21):
    $hp = 3;
    break;
  default:
    $hp = 4;
}
require_once "homepage$hp.php";
exit();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top