Solved

Outputting multiple records in one table row

Posted on 2001-08-20
8
201 Views
Last Modified: 2013-12-24
I am basically trying to do this but i dont know how to go about doing it. I have a table full up part information. Each part belongs to a category. I want to output the part info grouped by category so that the first column of the table shows you the recordcount of how many parts belong to the category, the second column gives you the partno's, with each partno on a new line. Kind of like 3 rows but in one table row. Anybody know if this is possible using cold fusion?
0
Comment
Question by:dmatthews
[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
8 Comments
 
LVL 5

Expert Comment

by:Yog
ID: 6407840
<cfoutput group="categoryname" name="yourqueryname">
<tr>
<td rowspan="#totalnoofrecords#">#recordcount#</td>
<cfoutput>
<td>#partno#</td>
</cfoutput>
</tr>
</cfoutput>

cheers.
0
 
LVL 4

Expert Comment

by:CF_Spike
ID: 6408158
What database are you using?

Spike
0
 
LVL 4

Accepted Solution

by:
CF_Spike earned 200 total points
ID: 6408184
Assuming your query looks like this:

<CFQUERY DATASOURCE="tests" NAME="qParts">
SELECT categoryname,partnum,partinfo
FROM parts
</CFQUERY>

The code below should produce a table formatted the way you want.

<TABLE BORDER="1">
<CFOUTPUT QUERY="qParts" GROUP="categoryname">
<TR>
     <TD COLSPAN="3">#qParts.categoryname#</TD>
</TR>
<TR>
     <TD>Part Count</TD>
     <TD>Part Number</TD>
     <TD>Part Info</TD>
</TR>
<TR>
     <!--- initialize a counter so we know how many rows to span with the left hand cell--->
     <CFSET count = 0>
     <!--- initialize the grouped cells to an empty row for this category --->
     <CFSET groupedcells = "">
     <CFOUTPUT>
          <!--- increment the counter --->
          <CFSET count = count + 1>
          <!--- build the HTML string for the grouped cells --->
          <CFSET groupedcells = groupedcells & "<TD>#qParts.partnum#</TD><TD>#qParts.partinfo#</TD></TR><TR>">
     </CFOUTPUT>
     <!--- use the count variable to determine the rowspan for this category --->
     <TD ROWSPAN="#variables.count#">#variables.count#</TD>
     <!--- ouput the HTML string for the grouped cells --->
     #variables.groupedcells#
</TR>
</CFOUTPUT>
</TABLE>

Spike
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:dmatthews
ID: 6408185
I am using an ingres database
0
 
LVL 6

Expert Comment

by:dash420
ID: 6409394
I don't know why u are getting problem. I think because of No of record
u are getting problem. if that is case break the query. First get the record count
i.e.

<cfoutput>
<cfquery name="qryTest" datasource="dsn">
   select count(*) cnt, category _id
   from table
   group by category_id
</cfquery>

<table>
    <cfloop query="qryTest">
       <tr>
           <td> #cnt# </td>
           <cfquery name="qryTest1" datasource="dsn">
              <!---
                   Query to Get details by passing the category_id
              --->
              Select * from table
              where category_id = #category_id#
           </cfloop>
           <td>
              <table>
                  <cfloop query="qryTest1">
                     <tr>
                         <td>your second query fields</td>
                     </tr>
                  </cfloop>  
              </table>
           </td>
       </tr>  
    </cfloop>
</table>
</cfoutput>

I think this will solve ur problem, if not let me know what is ur problem briefly.
0
 

Author Comment

by:dmatthews
ID: 6409657
The data comes from 3 tables. 1st table has the partno, part descr, and qty. The 2nd table is a master table for all components and is related to the first through partno. Also the categorycode for the part is in the 2nd table. So the part info is in the first table and the categorycode for the part comes from the 2nd table.
0
 

Author Comment

by:dmatthews
ID: 6409660
Sorry, i meant 2 tables.
0
 

Author Comment

by:dmatthews
ID: 6409763
Works like a charm. all i have left to do now is to remove the borders from with in rows. Thanks!!!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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