EasyCFM.COM ColdFusion Forums / Coding Help! / Array Help

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Array Help -- page: 1 2

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

jaco5md
07-24-2006 @ 10:25 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 492
Joined: Jul 2005

I need an array or "something" where I can display the following data in the following format.
     
DATA
ROOM                             StartDate                       EndDate
2024 Bldg Room 2-1000     10/16/2006 8:00:00 AM     10/16/2006 12:00:00 PM
2024 Bldg Room 2-1000     10/16/2006 1:00:00 PM     10/16/2006 5:00:00 PM
2024 Bldg Room 2-1000     10/17/2006 8:00:00 AM     10/17/2006 12:00:00 PM
2024 Bldg Room 2-1000     10/17/2006 1:00:00 PM     10/17/2006 5:00:00 PM
2024 Bldg Room 2-1000     10/18/2006 8:00:00 AM     10/18/2006 12:00:00 PM
2024 Bldg Room 2-1000     10/19/2006 1:00:00 PM     10/19/2006 5:00:00 PM


REPORT DISPLAY
Room                                10/16   10/17   10/18   10/19
----------------------------------------------------------
2024 Bldg Room 2-1000           X         X        AM       PM

X = The room is available in the morning and afternoon
AM = Room is only available in the morning
PM = Room is only available in the afternoon

I am totally frustrated with this and can use any and all help.  Thanks in advance!

-David

"It's only Rock 'n' Roll, but I like it"

jarottman
07-24-2006 @ 11:33 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 679
Joined: Sep 2004

So, got it code to show us? First off you really dont need an array. I will go ahead and assume that you are using a db for this classroom schedule project.

So why not use your database to handle the information, and use sql/cf to process and output it?

| There's no place like /root | There's no place like /root | There's no place like /root |

jaco5md
07-24-2006 @ 11:35 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 492
Joined: Jul 2005

Any suggestions on how I can get SQL to handle this?

-David

"It's only Rock 'n' Roll, but I like it"

twista
07-24-2006 @ 11:43 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 232
Joined: Jun 2006

Are you pulling that data from a database?
Or is it just a one time thing that doing with no plans on updating ever again?

If you're not using a database, I would check into using xml.. if you dont want xml..

you could always input that data into an array of structures.

ie.


<cfscript>
var aData = ArrayNew(1);

aData[1] = StructNew();
aData[1].Room = "2024 Bldg Room 2-1000";
aData[1].StartDate = CreateDateTime(InsertTimeHere);
//etc, etc
//This is your daily report array.. you'd load the dates in, 10/16 = 1, and so on. Then we'll access them with a switch later.
aData[1].Report = ArrayNew(1);
aData[1].Report[1] = "both";
//10.17
aData[1].Report[2] = "both";
//10.18
aData[1].Report[3] = "AM";
//10.19
aData[1].Report[4] = "PM";
</cfscript>

<table>
<tr>
<td>Room</td>
<td>Start Date</td>
<td>End Date</td>
</tr>

<cfoutput>
<cfloop from="1" to="#ArrayLen(aData)#" index="i">
<tr>
<td>#aData.Room#</td>
<td>#DateFormat(aData.StartDate, "short")# #TimeFormat(aData.StartDate, "medium")#</td>
<td>#DateFormat(aData.EndDate, "short")# #TimeFormat(aData.EndDate, "medium")#</td>
</tr>
</cfloop>
</table>
</cfoutput>


I'd imagined you'll be able to figure out the rest from there.. this is by no means the only method and I just thought of it off the top of my head so it's likely to be poor in performance. But hopefully it sparks your imagination.


-------------
-Morgan
Lead Trainer of the Ninja Squirrels

jaco5md
07-24-2006 @ 11:45 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 492
Joined: Jul 2005

I appreciate the help.  The data are in a DB and it will be updated from time to time.

-David

"It's only Rock 'n' Roll, but I like it"

twista
07-24-2006 @ 11:54 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 232
Joined: Jun 2006

in that case, completely ignore what I said :P

-------------
-Morgan
Lead Trainer of the Ninja Squirrels

jarottman
07-24-2006 @ 11:55 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 679
Joined: Sep 2004

Again can you post some code. We are here to help not do.
How is your database setup? Give us something a little more then how do I do this.

cflock of seagulls?

jaco5md
07-24-2006 @ 12:06 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 492
Joined: Jul 2005

Hey jarott.  I totally understand that you want to see some of my code, however, I have no idea where to start writing code for this task.  I only have the DB query that gives me the data displayed in my original post.

From there, I have no idea how to write a structure or array to cut and display the data in the way that I need.  If I had any other code I would be more than happy to post it.

I was hoping someone could say; OK you need an array or structure to get "this" data and then another array to get "that" data and then another and so on...

I am not a CF novice, however, array's and structures do cause me some problems.  Thanks again for your help and attention!

-David

"It's only Rock 'n' Roll, but I like it"

jarottman
07-24-2006 @ 2:05 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 679
Joined: Sep 2004

You dont need to use a struct or array for this at all.

You could do it like this

<cfquery name="roomQry" datasource="myDSN">
select field1, field2....
from yourTable
where room = 'roomId'
</cfquery>

Then use tables to output your data, etc...



cflock of seagulls?

jaco5md
07-24-2006 @ 2:10 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 492
Joined: Jul 2005

But the rooms will be dynamic, the data will be modified.  Each time a room is added I would need to add more code, yes?

-David

"It's only Rock 'n' Roll, but I like it"

PAGE: 1 2
Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.