adb64

msg:3990137 | 6:22 am on Sep 16, 2009 (gmt 0) |
Hi old_expat, Base the index on the current day number $RotateEveryXDays = 3; // Every 3 days another banner $banners_array = array ( 'tip1.php', 'tip2.php', 'tip3.php', 'tip4.php', 'tip5.php' ); $DayNr = time() / 86400; // Get day number (86400 = # seconds per day) $BannerNr = $DayNr / $RotateEveryXDays; // WHich banner to use for this day $i = $BannerNr % count($banners_array); // But limit to number of available banners $banner = $banners_array[$i]; include_once $banner;
Regards, Arjan
|
Lexur

msg:3990144 | 6:47 am on Sep 16, 2009 (gmt 0) |
The simplest way: <?php include "files/".date('m').date('d').".txt" ; ?> and then fill the folder files/ with text files called 0101.txt till 3112.txt to have a tip for every day of the year.
|
old_expat

msg:3990687 | 2:31 am on Sep 17, 2009 (gmt 0) |
Hello adb64, Thanks so much. I'm kind of a dummy, so may I assume that the only value I need to change is the '3' in order to set the rotation? $RotateEveryXDays = 3; // Every 3 days another banner $banners_array = array ( 'tip1.php', 'tip2.php', 'tip3.php', 'tip4.php', 'tip5.php' ); $DayNr = time() / 86400; // Get day number (86400 = # seconds per day) $BannerNr = $DayNr / $RotateEveryXDays; // WHich banner to use for this day $i = $BannerNr % count($banners_array); // But limit to number of available banners $banner = $banners_array[$i]; include_once $banner;
I will work my way through this one line at a time and try to learn a little bit more about PHP .. onward and upward. :)
|
old_expat

msg:3990688 | 2:41 am on Sep 17, 2009 (gmt 0) |
@Lerxur - I'm not sure I understand how this code works. What if I want to rotate only 2 files? (in one case I do want only 2) And I want each file to display for 'X' days. One thing I am trying is alternating a few affiliate text links vs a block of Adsense code. In another case I want to alternate several different Adsense blocks .. partly for testing, partly for ad blindness.
|
Lexur

msg:3990734 | 5:45 am on Sep 17, 2009 (gmt 0) |
You can reduce to this: <?php include "files/".date('d').".txt" ; ?> and fill the files/ folder with files from 01.txt to 31.txt and use odd files to Adsense and even to links (or whatever you want). Anyway yo must write/copy and rename the 31 files. The easy way is using the copy command and the old batch files.
|
adb64

msg:3990850 | 11:11 am on Sep 17, 2009 (gmt 0) |
old_expat, The 3 indeed defines the rotation frequency in days, so every 3 days the banner is changed. If you want to change once a week, change it to 7. Regards, Arjan
|
old_expat

msg:4004683 | 6:30 am on Oct 10, 2009 (gmt 0) |
This is probably a dumb question, but can a PHP script like this display a given file on a given day of the week?
|
coopster

msg:4015964 | 11:45 pm on Oct 29, 2009 (gmt 0) |
Yes. The date() function can tell you which day of the week it is. You can pull the given file for the given day of the week based on the switch. Off the top of my head, I believe it is "w" but you'll have to check the manual page to be certain.
|
|