|
|
Joined: Oct 2003
Posts: 2,305
Old Hand
|
Old Hand
Joined: Oct 2003
Posts: 2,305 |
Got a question I know I am missing it.. I need a formula for this I have 7 items and there are 31 days and I would like to use each item once a day and then go back to the beginning on day 8 and then use items again and over and over until day 31.. whats the formula. you can use x and y or write it up in php I don;t care I just need the formula 
|
|
|
|
Joined: May 1999
Posts: 3,039
Guru
|
Guru
Joined: May 1999
Posts: 3,039 |
Are you looking for a one line formula, or a code snippet/loop?
UBB.threads Developer
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
I thought this would be a fun question to throw around my IT department here at work, here are the responses so far.
1. From our scripting guy, mostly KIX:
Assuming $i is Day of week.
FOR $i = 0 to 6
IF item.date < 31 THEN
-- Use item
-- move to “example”
END IF NEXT
2. From our DB guy:
31days divided by 7items = number of times items can be reused.
|
|
|
|
Joined: Oct 2003
Posts: 2,305
Old Hand
|
Old Hand
Joined: Oct 2003
Posts: 2,305 |
I came up with.
$daysinmonth=date('t',time()); $ammountofcomics = count($local_files)-1; for($rotatecomics = 0; $rotatecomics <= $daysinmonth; $rotatecomics++) { $random_comic_array[]=($rotatecomics % $ammountofcomics)+1; }
$dayofweek=date('j',time()); $random_comic = $random_comic_array[$dayofweek]; $comics_image_name = $local_files[$random_comic]; $local_img_url = "{$comics_config['main_comics_url']}comics/"; $frontpage_comic = $local_img_url . $comics_image_name;
|
|
|
|
Joined: Mar 2003
Posts: 215
Junior Member
|
Junior Member
Joined: Mar 2003
Posts: 215 |
I don't think I understand this... You want to get the item given the day #? so 1 -> item 1 2 -> item 2 7 -> item 7 8 -> item 1 Is that what you want? Just go: Day -> item (Day % 7)+1
Last edited by RandyJG; 04/09/2004 2:41 PM.
|
|
|
|
Joined: Oct 2003
Posts: 2,305
Old Hand
|
Old Hand
Joined: Oct 2003
Posts: 2,305 |
yeah I have a varrying ammount of items and a fixed number of days per month and needed the calculation.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 417
Joined: November 2001
|
|
Forums63
Topics37,575
Posts293,930
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|