EasyCFM.COM ColdFusion Forums / Coding Help! / displaying query results in different colors?

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: displaying query results in different colors?

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

devondago
03-25-2003 @ 9:55 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 38
Joined: Feb 2003

I have results from a query that I am bringing in this way...
                         <cfloop query = "getc" ><font size=1 color="000000" face=Verdana,Arial,Helvetica>#getc.chour#:#getc.cmin# #getc.eventdes#</font>
I would like for each result to be brought in in a different color is there a way to do this other than creating a table to referece the eventdes by color?


CJ
03-25-2003 @ 12:36 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

what would be the criteria to determine color?  time of day?

If so (and assuming chour is 24 hour format)...

<cfloop query="getc">
     <cfif chour LT 10>
          <font size="1" color="##000000">#myData#</font>
          </font>
     <cfelseif chour GTE 10 AND chour LT 6>
          <font size="1" color="##ff0000">#myData#</font>
          </font>
     <cfelse>
          <font size="1" color="##0000ff">#myData#</font>
          </font>
     </cfif>
</cfloop>

This will check the chour variable and output a different color for morning, afternoon, and evening.

This is a very very basic example, and can be done much more robustly...i just figured i'd wait until i heard back regarding exactly what it was you want to do Smile

hth,
CJ

devondago
03-25-2003 @ 1:46 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 38
Joined: Feb 2003

What I would like is to see the eventdes come in with different colors. lets say
tennis 7:00 (blue text)
Bowling 8:15 (green text) etc....
I hope you follow me.
thanks for the help!

Webmaster
03-25-2003 @ 2:08 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

You could use the same mechanism as in this tutorial:
http://tutorial22.easycfm.com/


<cfloop query = "getc" >
   <font size=1 color="###iif(currentrow MOD 2,DE('0000ff'),DE('ff0000'))#" face=Verdana,Arial,Helvetica>#getc.chour#:#getc.cmin# #getc.eventdes#</font>
</cfloop>

That will give you alternating colors Playful Wink

Thanks,
Pablo Varando

=====================================================

devondago
03-25-2003 @ 3:04 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 38
Joined: Feb 2003

Thank YOU it works...I am reaching here but how about if i have 6 events coming in? I noticed you tried with 2 but in the event that i have more how would I increase it?
like this?
<cfloop query = "getc" ><font size=1 color="####iif(currentrow MOD 3,DE('000080'),DE('ggccgg'),DE('cccccc'))#" face=Verdana,Arial,Helvetica>#getc.chour#:#getc.cmin# #getc.eventdes#</font>
please let me know.

Webmaster
03-25-2003 @ 3:13 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

no, this will work with two, if you change to 6 it will change color every 6th row.

If you want to go up you will need to change it, that will work for two only. Playful Wink




Thanks,
Pablo Varando

=====================================================

CJ
03-25-2003 @ 4:20 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

i'm still confused (big surprise) Smile

Are you simply trying to alternate row colors?  Or are you trying to color a row based on a specific value (such as time of day or event type)?

CJ

devondago
03-26-2003 @ 9:31 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 38
Joined: Feb 2003

What I am trying to do is to display each record coming in through my query on a different color. Lets say I have 7 records coming in with this query.
                         <cfloop query = "getc" ><font size=1 color="###iif(currentrow MOD 2,DE('000080'),DE('ggccgg'))#" face=Verdana,Arial,Helvetica>#getc.chour#:#getc.cmin# #getc.eventdes#</font>
what I want to see is each display on a differnt color. I have been playing around with the suggestion that Pablo gave and it works. (thank you Pablo!) but now that I have inputted more records to those fields I wanted to explore a way to have them display on colors rather than just 2 that I currently have. I know that I can reference the records if I create another table and by their ID display a color for them but since we dont have to display all records by a particular class we can as well have them come in just with a dirrent color each.
Hope it helps my explanation.
thanks

CJ
03-26-2003 @ 1:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

well, the code Pablo gave is for alternating table row colors...commonly used in tabular data format.

to answer the question you posed above (regarding increasing the MOD number), that would give you every third row color1, and any other row color2.  essentially, it just uses two different colors.

The problem that I'm still having with what you want to do is...you're going to need to define a list of colors.  what happens if you have more records out than colors?  should it start over?

What's the advantage of outputting every row in a different color?  

Just trying to get a grasp on the requirements here.

CJ


Website Designed and Developed by Pablo Varando.