EasyCFM.COM ColdFusion Forums / MS Access Related Issues / Table realations

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Table realations -- page: 1 2 3

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

MIGhunter
03-03-2007 @ 11:40 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

Sorry for the noob question but setting up tables always perplexes me.  

Here is what I want to do.  This is kinda a calendar application but not in a calendar format.  Basically the page will have the 12 months in a column on the left.  Then when you click on a month, it will load all the classes in a frame on the right.  

So, when setting up the database, would it be best to set up 1 table with just jan-dec in it and then set up 12 additional tables with the 28-31 days of the month?  If so, for the 12 tables do I make the primary key the month and how do I link them?  Thanks.

GrowlyBear
03-04-2007 @ 2:25 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1314
Joined: May 2004

keep it simple as possible.
table: classes
col 1: id (primary key)
col 2: class_name
col 3: class_details
col 4: date_time

left frame is using dateadd and a cfloop to give you 12 months. this way it works without you having to edit the page.

right frame simple query to get classes for the month using col 4 which is date time.


~~~~~~~~~~~~~~~~~~~
CF Blogger
http://www.cfblogger.com

MIGhunter
03-08-2007 @ 10:43 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

ok so left frame uses date add for the months but how do you turn the months into hyperlinks that puts all the classes for that month into the right frame?  Is it the same as a master - detail set?

GrowlyBear
03-09-2007 @ 12:52 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1314
Joined: May 2004

left frame
<cfloop index=x from=1 to=12>
<a href="page.cfm?month=#x#" target=rightframe>monthasstring(x)</a><br />
</cfloop>

right frame
query * where month(date_time) =url.month

this is all rough i have not checked it but the logic is there.

so you only need the db for the classes.

~~~~~~~~~~~~~~~~~~~
CF Blogger
http://www.cfblogger.com

MIGhunter
03-09-2007 @ 1:23 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

ok so I was playing with it a little.  How do you get the DateAdd() function to work?  Here is the code I have and it displays 12 months but they are all the same month.
<!--- Month loop --->
<cfloop from="1" to="12" index="i">

<!--- Output months --->
<cfoutput>#DateFormat(DateAdd("M", 1, 1), "MMMM")#</cfoutput><br>
</cfloop>


GrowlyBear
03-09-2007 @ 1:45 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1314
Joined: May 2004

if all you need is just the months my earlier example will do the trick.


thry this

<cfoutput>
<cfloop from="1" to="12" index="i">
#DateFormat(createdate(year(now()),i,1), "MMMM")#
<br></cfloop></cfoutput>

using now() for example purposes
if you want jan for any year then use createdate(year(now()),1,1)

~~~~~~~~~~~~~~~~~~~
CF Blogger
http://www.cfblogger.com

MIGhunter
03-09-2007 @ 2:11 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

<cfoutput>
<cfloop from="1" to="12" index="i">
#DateFormat(createdate(year(now()),i,1), "MMMM")#
<br></cfloop></cfoutput>  

Ok, so this worked for giving me the months.  Thanks.

This however I am having problems following:
<cfloop index=x from=1 to=12>
<a href="page.cfm?month=#x#" target=rightframe>monthasstring(x)</a><br />
</cfloop>  

Using this code, I got this: http://www.botdls.com/ChristinaRidgeWebsite/CodeTesting/datetest.cfm

Why doesn't it show the months?

MIGhunter
03-09-2007 @ 2:19 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

oops, i'm dumb, 2:30am at work playing around.  I got it to work combing your 2 samples.
<cfloop index=x from=1 to=12>
<a href="page.cfm?month=#x#" target=rightframe><cfoutput>#DateFormat(createdate(year(now()),x,1), "MMMM")#</cfoutput>
</a><br />
</cfloop>  


This message was edited by MIGhunter on 3-9-07 @ 2:20 AM

GrowlyBear
03-09-2007 @ 2:19 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1314
Joined: May 2004

is there a cfoutput around it? and the monthasstring is missing the pound signs. it should look like below?
<cfoutput>
<cfloop index=x from=1 to=12> <a href="page.cfm?month=#x#" target=rightframe>#monthasstring(x)#</a><br /> </cfloop></cfoutput>

[edit]
somehow your reply has appeared above mine so ignore this.
~~~~~~~~~~~~~~~~~~~
CF Blogger
http://www.cfblogger.com

This message was edited by GrowlyBear on 3-9-07 @ 2:31 AM

MIGhunter
03-09-2007 @ 2:38 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 570
Joined: Apr 2006

Now, I just gotta make the database and play around with it to make the dates link.  I'll repost here if I have anymore problems.  Thanks for all your help.  This has to be the best forum for CF.

PAGE: 1 2 3

Website Designed and Developed by Pablo Varando.