Solved

Build dynamic table output

Posted on 2014-11-03
1
155 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

17 Experts available now in Live!

Get 1:1 Help Now