Solved

Build dynamic table output

Posted on 2014-11-03
1
145 Views
Last Modified: 2014-11-04
I am trying to figure out a way on how to display the output of a database query in coldfusion
a bit different. Instead of having data displayed in rows and the columnheader is the field
name, i want to have the field names in the rows and each record show be a seperate column.

Like this

User ID           00               01              02
Name             Tom            Steve         Mike
Gender           M                M                M

What is the best way to achieve this ?

Thanks
0
Comment
Question by:AlexPonnath
1 Comment
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 40420689
The key is to refer to each query value using the structure format, that way you don't have to do the traditional CFOUTPUT loop, but can control your loop.

Reference name using    myQuery['name'][kk]   where kk is the row number and the column name is in quotes 'name'

So now you can loop across the row and have each column with a different record, like this..

<tr>
  <td>Name</td>
<cfloop index="kk" from=1 to="#myQuery.recordCount#">
    <td>#myQuery['name'][kk]#</td>
</cfloop>
</tr>

do the same for the other columns..
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now