ASP week populated Drop Down

Panda On Smack

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,030
Hi chaps

Ive got a game which will run between years i.e. start in august and go on into may the following year. What i need to do is have a drop down which is populated by the current week of the game, not year, so a user can choose that week and see how he and everybody else did that week. I store all the scores on a weekly basis in a table. If my game starts in december then by January im roughly in week 5.

I can only thing of doing a calculation on the current week of the year somehow but i cant seem to get it to work both sides of the year.

I use the drop down in a few pages and the start week and end week of the game are declared in an include file so i can change them easily.

Does that make sense? Any ideas would or solutions would be great.

Thanks
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Nothing ASP specific, but what if you were to translate week numbers into "Week beginning" dates?

You have somewhere in your data store the information for the start of "Season 1". You record the start as "1st December 2004" and the script translates week numbers based on that?

Consider the following - for which I'm making some assumptions about your project, I also tend to think and describe in database terms with this kinda thing, but it applies to file based storage as well, just not as slickly.

Week themselves could be internally stored by "Week beginning date", and when retrieved will be returned in date order.
When the weeks are retrieved and you loop through them to generate the Drop Down box, rather than output the Week Beginning date, you could instead have a counter running alongside it and output "Week: $count" as the text content.

As to whether weeks exist on their own, on whether they only exist through events in the game is obviously down to your system: If they exist on their own (containing unique information or something) then it'll be easier to grab them.

If they just exist purely as a data field on game events (e.g. datetime of the event) then you may find that you need to include 2 date fields: 1 for the actual date/time of the event, and a second for the "week begininning", in the interests of extracting the data more quickly (I imagine that taking a take and calculating the week beginning for each record would be slow, so probably better just to store it).

That would certainly work, as to whether it's the best solution is up to the more experienced mob :)
 

Panda On Smack

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,030
Nice one squire

you have opened my eyes to an option and its worked out well, proper b0

Cheers
 

Shovel

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,350
Ahh I'm glad?

Can I ask what it is you're going to do?
 

[UKLans]Khan

Fledgling Freddie
Joined
Dec 23, 2003
Messages
52
No sure that I get you but does this help:

Code:
<%
Dim Var_StartDate = "01-02-2004"
Dim Var_EndDate = "02-02-2005"
Dim Var_tmpdate
Dim tmpStr

tmpStr = "<select>"
Var_tmpdate = Var_StartDate

Do until Var_StartDate =>Var_EndDate
  tmpStr = "<option value='" & Var_tmpdate & "'>" & Var_tmpdate & "</option>" 
  Var_tmpdate = DateAdd("ww","1",Var_tmpdate)
Loop

tmpStr = "</select>"

Response.write tmpStr
%>

Not sure if this will help or not,

Khan
 

Panda On Smack

Can't get enough of FH
Joined
Dec 22, 2003
Messages
1,030
Soz, just noticed more activity here.

It is football related yeah, it’s actually to do with Sky believe it or not.

Will show you when it’s up and running.

Khan, I basically needed a dropdown which listed from whenever I set the start date of the game as week 1 to however long I decided the game was going to last. Sounds simple but I went down a complicated route. I store the scores for each week in a database as ‘01’ or ‘18’ and use it for easy retrieval. I also have a date field so I know exactly when the score was stored.
 

Users who are viewing this thread

Top Bottom