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 7days. so it displays different content
every week.
like week one it shows
"main content 1"
week two "main content 2"
week 3 main content 3 .... and so on
can this be done?
php codeing help
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php codeing help
Code: Select all
$filename = 'main_content' . (date('w') + 1) . '.php';
include $filename;(#10850)
Re: php codeing help
thank you,
but i have 1 more question,
would this code return back to the first "main content" after the last "main content"
example,
lets say i have 5 different main content i want to cycle every week,
would it show main content #1 on week 6?
and content #2 on week 7 and so on...
what is the code for that?
but i have 1 more question,
would this code return back to the first "main content" after the last "main content"
example,
lets say i have 5 different main content i want to cycle every week,
would it show main content #1 on week 6?
and content #2 on week 7 and so on...
what is the code for that?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: php codeing help
For any date information look at the date() function. You probably want to get the modulus from dividing the week of the year by the number of week in the rotation.
http://us.php.net/manual/en/function.date.php
http://us.php.net/manual/en/language.op ... hmetic.php
http://us.php.net/manual/en/function.date.php
http://us.php.net/manual/en/language.op ... hmetic.php
(#10850)