Solved

Outputting multiple records in one table row

Posted on 2001-08-20
8
193 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
8 Comments
 
LVL 5

Expert Comment

by:Yog
Comment Utility
<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
Comment Utility
What database are you using?

Spike
0
 
LVL 4

Accepted Solution

by:
CF_Spike earned 200 total points
Comment Utility
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
 

Author Comment

by:dmatthews
Comment Utility
I am using an ingres database
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 6

Expert Comment

by:dash420
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry, i meant 2 tables.
0
 

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

16 Experts available now in Live!

Get 1:1 Help Now