Savage Vines | Recently... | Elsewhere | Search | Login |

This is the area where you can put a text about yourself or your blog. You can change the colours and the layout as you like, but please keep the footer link the way the way it is so that other can find the way back to me. Thanks for using this theme, I really appreciate it. This theme is released under those Creative Commons terms of use. And now ENJOY and get blogging!

continue reading this article






fancy

Trick to displaying Multiple Query Columns for a list

26 08 2004

I was answering a fellow CFer on a mailing list called CF-Talk and he was asking how to eliminate the extra commas you get if you have multiple columns from a query that you just need to output as a list (ex. “joe, billy, kyle”). If you do this (look below) you will get extra commas if a column is blank.

<cfoutput query="yourQuery">
<p>#friendname1#, #friendname2#, #friendname3#, #friendname4#, #friendname5#</p>
</cfoutput>

Your output would be:

john, , william, samuel,

I use this technique to avoid this issue. Loop over a list and you woun’t run into this.

<cfoutput>
<cfset Practice = "john,jane,clyde,bobo,sammy,beth">
<p><cfloop index="i" from="1" to="#listlen(Practice)#"><cfif i GT 1>, </cfif>#listgetat(Practice,i)#</cfloop></p>
<cfset Practice = "john,,clyde,,sammy,">
<p><cfloop index="i" from="1" to="#listlen(Practice)#"><cfif i GT 1>, </cfif>#listgetat(Practice,i)#</cfloop></p>
</cfoutput>

categories Published under: Cold Fusion


Leave a message or two

Name (required)

Email (required)

Website



XHTML: The following tags are allowed:

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please leave a comment








  • Recent Comments

  • Recent Posts

  • Meta

  • Flickr

  • 0906070122.jpg
  • Linda and Amanda in car
  • Linda and Amanda in car
  • Baca with the girls
  • late night walk
  • more late night walking