ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old May 16th, 2004, 06:15 PM
elena_t elena_t is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 elena_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
alphabetical list

Hi everyone. I have a list of 35 categories (in an Access database), which I would like to output to a Web page, in a table, in three colums, arranged vertically. I need to close a <td> when 12 records have been displayed, or something like that... Any idea how to do this?
Thanks,
E

Reply With Quote
  #2  
Old May 17th, 2004, 08:23 AM
bfolger71 bfolger71 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Boston, MA
Posts: 47 bfolger71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 34 sec
Reputation Power: 5
Use 3 separate loops, starting and ending at the appropriate places. You might want to calculate, and then set to variables, the values for the end and beginning of each column. That way, if your data changes, your page compensates automatically.

<table>
<tr>
<td>
<cfloop query="yourQueryName" STARTROW=1 ENDROW=#FirstColumnEnd#>
<p>#yourQueryResult#</p>
</cfloop>
</td>
<td>
<cfloop query="yourQueryName" STARTROW=#SecondColumnBegin# ENDROW=#SecondColumnEnd#>
<p>#yourQueryResult#</p>
</cfloop>
</td>
<td>
<cfloop query="yourQueryName" STARTROW=#ThirdColumnBegin# ENDROW=#yourQueryName.Recordcount#>
<p>#yourQueryResult#</p>
</cfloop>
</td>
</tr>
</table>

Reply With Quote
  #3  
Old May 17th, 2004, 08:25 AM
J4MIE J4MIE is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Sunny Scotland
Posts: 2 J4MIE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Easy

Hi,

It's quite easy to do.

You need to have a counter that has the number of columns in it. Then, inside the cfoutput you need to increment this. Then you check it and if necessary, close a row and start a new one.

<cfset counter = 0>

<cfoutput query="myQuery">

<cfset counter = IncrementValue(counter)>

<cfswitch expression="counter">
<cfcase value="3"> </tr><tr> </cfcase>
<cfcase value="6"> </tr><tr> </cfcase>
<cfcase value="9"> </tr><tr> </cfcase>
<cfcase value="12"> </tr><tr> </cfcase>
<cfcase value="15"> </tr><tr> </cfcase>
<cfcase value="18"> </tr><tr> </cfcase>
<cfcase value="21"> </tr><tr> </cfcase>
<cfcase value="24"> </tr><tr> </cfcase>
<cfcase value="27"> </tr><tr> </cfcase>
<cfcase value="30"> </tr><tr> </cfcase>
<cfcase value="33"> </tr><tr> </cfcase>
</cfswitch>

<td>#myCategory#</td>

</cfoutput>



Should do the trick.

Reply With Quote
  #4  
Old May 17th, 2004, 09:25 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,492 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 25 m 21 sec
Reputation Power: 44
You can do this in just a few lines of code using the MOD operator:

Code:
<table border="1">
<cfoutput query="categoryQuery">
<cfif categoryQuery.currentRow MOD 3 EQ 1>
	<tr>
</cfif>
	<td>#categoryQuery.categoryName#</td>
<cfif categoryQuery.currentRow MOD 3 EQ 0>
	</tr>
</cfif>
</cfoutput>
</table>

Reply With Quote
  #5  
Old May 17th, 2004, 11:21 AM
elena_t elena_t is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 elena_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for the replies! Unfortunately, none of them worked :-( The one using the MOD function works in the sense that it indeed aranges records in three columns. However, this is an alphabetical list and I want the items to appear alphabetically in a vertical manner. With the MOD solution, categories such as Air Pressure, Analog Data, Cable ... appear arranged horizontally, instead of one underneath each other.

The solution regarding setting FirstColumnBegin, FirstColumnEnd, etc. variables almost worked --- the table appeared fine, I received no errors, except that the query results were not displayed. All I got was #getcategories#, which appeared 27 times, in 3 columns :-) Is there anything else that I may need to specify in the <cfloop>?

The third solution, regarding the counter set did not work at all - maybe I did not understand how to implement it? All I got was one <td> with all the records in it...I placed all the code you indicated (with the exception of setting the counter) within a <tr>. Is this wrong?
Thanks again. Any further ideas would be appreciated!
E

Reply With Quote
  #6  
Old May 17th, 2004, 11:59 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,492 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 25 m 21 sec
Reputation Power: 44
Yes, that will be rather difficult because a table with 3 columns MUST be built from the top down, which is totally incompatible with the order that the query is returning the result set.

The two options that I could think of are modifying the SQL statement to get things into an order that allows you to output them using a table. But this will require some rather messy SQL and conditional logic in the ORDER BY clause.

The second option would be to calculate what the next value should be within each loop iteration. This also seems like it would be rather messy, requiring the use of arrays or lists.

I guess what I'm saying is that doing what you want is going to be quite difficult. I'm sure it's possible, but the amount of work it will take to do it might outweigh the advantage of having the order go down instead of across.

Last edited by kiteless : May 17th, 2004 at 12:05 PM.

Reply With Quote
  #7  
Old May 17th, 2004, 01:32 PM
bfolger71 bfolger71 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Boston, MA
Posts: 47 bfolger71 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 34 sec
Reputation Power: 5
Quote:
Originally Posted by elena_t
The solution regarding setting FirstColumnBegin, FirstColumnEnd, etc. variables almost worked --- the table appeared fine, I received no errors, except that the query results were not displayed. All I got was #getcategories#, which appeared 27 times, in 3 columns :-) Is there anything else that I may need to specify in the <cfloop>?


Yes, there's a missing <cfoutput> that needs to be wrapped around the whole thing.

Then it should work.. as long as you specify a fieldname... #getcategories.yourFieldName#

Reply With Quote
  #8  
Old May 17th, 2004, 03:10 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,492 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 25 m 21 sec
Reputation Power: 44
Quote:
Originally Posted by bfolger71
Yes, there's a missing <cfoutput> that needs to be wrapped around the whole thing.

Then it should work.. as long as you specify a fieldname... #getcategories.yourFieldName#
Ah, I see that you've bypassed the bulk of the problem by not using individual table cells for each element, only for each column. I had been assuming that a full table was desired. A nice alternate approach, as long as they can live with the fact that each element is not in its own cell.

Reply With Quote
  #9  
Old May 17th, 2004, 04:54 PM
elena_t elena_t is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 3 elena_t User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The solution worked perfectly! Thank you!

Reply With Quote
  #10  
Old May 17th, 2004, 10:23 PM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 182 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 16 h 41 m 17 sec
Reputation Power: 0
Talking A little late

Not to kick a dead horse but, i would use inline frames then do three simple queries, but then again i still eat Fruity Pebbles for breakfast so what do i know.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > alphabetical list


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway