Solved

Outputting multiple records in one table row

Posted on 2001-08-20
8
200 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
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
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to go to page 12 110
AWS New EC2 Instance and EBS Storage 2 94
Internal to DMZ IIS Authentication. 3 60
move expression web site to a new server 13 74
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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