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
Solved

Outputting multiple records in one table row

Posted on 2001-08-20
8
199 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

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

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…
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…
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…

809 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