Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamically creating a table

Status
Not open for further replies.

jgroove

Programmer
Jul 9, 2001
43
US
I have a query:

<cfquery name=&quot;qSessionInfo&quot;>
select distinct(Location),SessionDate
from Session
order by SessionDate desc
</cfquery>

that returns results like this:

dec 1,2001 new york
dec 1,2001 chicago
dec 1,2001 los angles
nov 1,2001 new york
nov 1,2001 chicago
nov 1,2001 los angles
oct 1,2001 new york
oct 1,2001 chicago
oct 1,2001 los angles
.
.
.


I want to produce a table that would display the information like this:

dec 1,2001 new york chicago los angles
nov 1,2001 new york chicago los angles
oct 1,2001 new york chicago los angles

I am having a major brain fart this morning and can't think how to start this, any ideas? Do I need to create a stuct? an array?

jgroove
 
No, you don't need an array or a struct. You can do it like this:
Code:
<CFOUTPUT QUERY=&quot;GetThreads&quot;>
	<DIV ALIGN=&quot;center&quot;>
	<TABLE CLASS=&quot;MultiColor&quot;>
	<CFIF #CURRENTROW# MOD 2 EQ 0>
		<CFSET COLOR=&quot;#Application.LightColor#&quot;>
		<CFELSE>
	<CFSET COLOR=&quot;#Application.Lighter#&quot;>
	</CFIF>
		<!---<CFIF NOT VAL(Form.Age) OR (Val(Form.Age) AND DateDiff(&quot;d&quot;,ThreadDate,Now()) LTE Form.Age)>--->	
	<TR BGCOLOR=&quot;#Color#&quot;>
		<TD><A HREF=&quot;ViewThread.cfm?ThreadID=#ThreadID#&quot;>#ThreadName#</A></TD>
		<TD>#MessCount#</TD>
		<TD>#DateFormat(LastPost,&quot;mmm dd, yyyy&quot;)#  #TimeFormat(LastPost,&quot;hh:mm tt&quot;)#</TD>
	</TR>
	</TABLE>
	</DIV>
	</CFOUTPUT>
Basically, just make a one row table the way you want it, and use <CFOUTPUT QUERY=&quot;qSessionInfo&quot;> Calista :-X
Jedi Knight,
Champion of the Force
 
Jedi Knight,

I am not sure that is it, it looks like all of your dynamic output for each line is from the same record. I want to combine multiple records onto the same line where all of the dates equal each other... does that make more sense?

jgroove
 
Looks like I'm the one having the brain fart. Guess I didn't read your question carefully enough. At the moment I'm drawing a blank, too, but I think the solution is going to involve reading the results into arrays. If I have any great flashes of insight, I'll let you know. In the meantime, maybe one of the &quot;real&quot; experts in this forum will come up with somthing. How about it, tleish? Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top