php codeing help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jwan84
Forum Newbie
Posts: 7
Joined: Wed Mar 26, 2008 9:51 pm

php codeing help

Post 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 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php codeing help

Post by Christopher »

Code: Select all

$filename = 'main_content' . (date('w') + 1) . '.php';
include $filename;
(#10850)
jwan84
Forum Newbie
Posts: 7
Joined: Wed Mar 26, 2008 9:51 pm

Re: php codeing help

Post by jwan84 »

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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php codeing help

Post by Christopher »

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
(#10850)
Post Reply