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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfcol to make new column?

Status
Not open for further replies.

doyle9732

Programmer
Apr 12, 2002
185
CA
I am generating a telephone list for 120 people with only their name and extension on the output. I have looked in the help area of CF and don't see an attribute to handle this. Ideally, I'd like the first 50 names to appear in the first column, the next 50 in a new column and the remaining to appear in the last column. When I use the max row attribute (for the table), it just stops the query at that number.

Anyone know?
Thanks!
Stephanie
 
You want to use 3 cfloops to make the 3 columns

<cfloop startrow="1" endrow="#Evaluate(query.RecordCount/3)#">
<td></td>
</cfloop>
<cfloop startrow="="#Evaluate(query.RecordCount/3 + 1)#" endrow="#Evaluate(query.RecordCount/3 * 2)#">
<td></td>
</cfloop>
<cfloop startrow="="#Evaluate((query.RecordCount/3 * 2) + 1)#" endrow="#query.RecordCount#">
<td></td>
</cfloop>
 
Something like this?
Code:
<cfset count = 0>
<table>
  	<tr>
    	<td>
    	<cfoutput query="whatever">
     		<cfset count = (count + 1)>
      		#Name#<br>
	      	<cfif Count EQ 50>
			<cfset count = 0>
				</td>
		         <td>
	     	</cfif>
		 </cfoutput>
		 </td>
	</tr>
</table>

Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
I wrote an faq for that. :)
faq232-5578

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Oh, sure...if you want to take the easy answer. (-:



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
that wasn't easy :) i spent an hour on that. then someone gave it a 2... >8|

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
still trying to adapt it to what I need (3 columns with 3 columns in it - name, extension, mailstop).....Originally I took out you [output] - until I realized I need that! I had 120 outputs of the same name! I'm confident I'll get it working - and I will be sure to rate the FAQ favourably! And I thank you all for responding!

BTW, I didn't get any of them working the first time..... just ended up with one looooong row.....but then the FAQ came to my attention. But I do appreciate all the quick responses!

Stephanie
 
This may be more specific to your needs.

<table>
<tr>
<td>
<table>
<cfloop query="queryname" startrow="1" endrow="#Evaluate(query.RecordCount/3)#">
<tr>
<td>#name#</td>
<td>#extension#</td>
<td>#mailstop#</td>
</tr>
</cfloop>
</table>
</td>
<td>
<table>
<cfloop query="queryname" startrow="#Evaluate(query.RecordCount/3 + 1)#" endrow="#Evaluate(query.RecordCount/3 * 2)#">
<tr>
<td>#name#</td>
<td>#extension#</td>
<td>#mailstop#</td>
</tr>
</cfloop>
</table>
</td>
<td>
<table>
<cfloop query="queryname" startrow="#Evaluate((query.RecordCount/3 * 2) + 1)#" endrow="#query.RecordCount#">
<tr>
<td>#name#</td>
<td>#extension#</td>
<td>#mailstop#</td>
</tr>
</cfloop>
</table>
</td>
</tr>
</table>
 
Adapting the faq will be easy assuming you can put all 3 in the same cell

the faq says this (basicly)
Code:
<td>
<cfoutput>#qMyQuery.myField[output]#</cfoutput>
</td>

You'd simply add the rest of the columns you need.
Code:
<td>
<cfoutput>#qContacts.lastName[output]#: x-#qContacts.ext[output]#</cfoutput>
</td>

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top