Previous Thread
Next Thread
Print Thread
Rate Thread
#272115 04/09/2004 1:36 AM
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

Sponsored Links
234234 #272116 04/09/2004 10:06 AM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Are you looking for a one line formula, or a code snippet/loop?


UBB.threads Developer
Sally #272117 04/09/2004 11:14 AM
Joined: May 2003
Posts: 1,068
Junior Member
Junior Member
Offline
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.

BlarC #272118 04/09/2004 11:43 AM
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;

234234 #272119 04/09/2004 2:40 PM
Joined: Mar 2003
Posts: 215
Junior Member
Junior Member
Offline
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.
Sponsored Links
romka #272120 04/12/2004 8:22 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.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)