Page 1 of 1

PHP newbi - need help

Posted: Wed Mar 26, 2008 9:59 pm
by jwan84
i have question about coding.
i have a website that currently has

include("main content");

to my main content.
i want the main content to cycle every 24hours. so it displays different content
every day.

like day one it shows
"main content 1"
day two "main content 2"
day 3 main content 3 .... and so on
can this be done?

Re: PHP newbi - need help

Posted: Sun Mar 30, 2008 5:59 pm
by AMCH
Hi there,

This can be done. Try something similar to the following:

As an example I am going to show you how to make it display based on which day of the week it is.

Code: Select all

// date("N") is a built in php function to establish the day of the week based on a number representation,
// 1 being Monday etc... it uses your system time/calendar to establish which day it is.
 
$day_to_include = date("N");
 
// the following concatenates the variable onto the end of "main_content"
 
$day_to_include = "main_content".$day_to_include."html";
 
// the following includes a file that is equal to the variable
 
include "$day_to_include";
With the above example:

If the day was Monday it will include "main_content1.html",
Tuesday will include "main_content2.html"... and so on...

Hope this helps.

Kind Regards
AMCH

Re: PHP newbi - need help

Posted: Wed Apr 02, 2008 5:18 pm
by jwan84
thax so much.
life saver!