Solved

How do I Flip a Table?

Posted on 2002-05-10
2
123 Views
Last Modified: 2013-12-24
Hi Guys!

How do I turn a CFQUERY record set that CFDUMPs like this:

<table border="1" cellspacing="0" cellpadding="1" bgcolor="#eeaaaa" bordercolor="Red">
     <tr bgcolor="#eeaaaa" >
     
          <td valign="top">DIVISION</td>
     
          <td valign="top">PROGRAM_NAME</td>
     
     </tr>
     <tr> <td valign="top" bgcolor="#ffffff"> Team </td> <td valign="top" bgcolor="#ffffff"> Bear Street </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> Team </td> <td valign="top" bgcolor="#ffffff"> Clipboard Solutions </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> Team </td> <td valign="top" bgcolor="#ffffff"> Emerson Associates </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> Team </td> <td valign="top" bgcolor="#ffffff"> Lake Avenue </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> Team </td> <td valign="top" bgcolor="#ffffff"> Smithfield road </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> Cambridge Health Alliance </td> <td valign="top" bgcolor="#ffffff"> The Beck Ward </td> </tr> <tr> <td valign="top" bgcolor="#ffffff"> North East </td> <td valign="top" bgcolor="#ffffff"> The Oliver Street House </td> </tr>
     </table>

into something like this:

<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="1" BGCOLOR="#EEAAAA" BORDERCOLOR="Red">
     <TR ALIGN="center">
          <TD COLSPAN="5">Team</TD>
          <TD COLSPAN="1">Cambridge Health Alliance</TD>
          <TD COLSPAN="1">North East</TD>
     </TR>
     <TR ALIGN="center" BGCOLOR="#FFFFFF">
          <TD COLSPAN="1">Bear Street</TD>
          <TD COLSPAN="1">Clipboard Solutions</TD>
          <TD COLSPAN="1">Emerson Associates</TD>
          <TD COLSPAN="1">Lake Avenue</TD>
          <TD COLSPAN="1">Smithfield road</TD>
          <TD COLSPAN="1">The Beck Ward</TD>
          <TD COLSPAN="1">The Oliver Street House</TD>
     </TR>
</TABLE>
0
Comment
Question by:dbabbitt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
Scott Bennett earned 100 total points
ID: 7001795
You could do something like this:

<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="1" BGCOLOR="#EEAAAA" BORDERCOLOR="Red">
<TR ALIGN="center">
<cfoutput query="MyQuery" group="Division">
     <cfquery name="GetCount" dbtype="query">
          SELECT Division
          FROM MyQuery
          WHERE Division = #MyQuery.Division#
     </cfquery>
         <TD COLSPAN="#GetCount.RecordCount#">#MyQuery.Division#</TD>
</cfoutput>
     </TR>
     <TR ALIGN="center" BGCOLOR="#FFFFFF">
     <cfoutput query="MyQuery"><TD>#MyQuery.Program#</TD></cfoutput>
     </TR>
</TABLE>
0
 
LVL 14

Expert Comment

by:Scott Bennett
ID: 7001797
that assumes you are doing a query like this:

<cfquery name="MyQueryName" datasource="MyDSN">
SELECT Division, Program
FROM MyTable
ORDER BY Division
</cfquery>
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…

733 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