Skip to main content
Inspiring
April 8, 2011
Question

Combine 2 rows into 1 row

  • April 8, 2011
  • 1 reply
  • 4396 views

Hi,

I'm not sure if this is possible or not, but I have 2 different columns in a display page- 1 for PNR Initials and 1 for BOM  Initials, but when I insert everything into the database, I only have 1  column to handle both the PNR and BOM initials. The way I tell them  apart is with another column that is called Document_Type. If it says  "PNR Req", then I know to output it into the PNR Initials column. If it  says "BOM Req", then I know to outupt it into the BOM Initials column.

      Although the inserting works correctly, the display page does not put  them next to each other since the data is dynamic and it's outputting each column's initials into their own rows. For instance, I updated the PNR Initial to "VP"  and hit the update or insert button and it inserted the PNR Initial  into the database. Then I went back to the display page to insert the  BOM Initial to "AG". It inserted it correctly. But now when I go back to  the display page, there are 2 different rows with the first row that  has the drop down menu in the PNR Column and "AG" in the BOM column. But  then there is another row that has "VP" in the PNR column and the drop  down menu in the BOM column. Since I've updated both columns, it should  just show the PNR Initials under the PNR column once and the BOM Initials under the BOM column once, but all in the same row and not on 2 separate rows. How do I  get it so they show up on the same row? The 2 different rows are indicated by the APVID 5 and 9, but they both are linked to the same item number 5 in the Items table. Here's what my display page  looks like now:

APVID
APV_ItemID
Part_Number
PNRBOM
55aaa5Drop Down MenuAG
95aaa5VPDrop Down Menu

It should look like this:

APVID APV_ItemID
Part_Number
PNRBOM
5 and 95aaa5VPAG

The  APV_ItemID is linked to a column in another table. That table is the  ECO_Items table that has the ItemID column that has all the items. The  info. above for the APV_ItemID and Part number can always all be the  same, but the PNR and BOM columns have to display the correct initals in  each on 1 line. I tried the maxrows and the group function on the output query, but those did  not work. I've also tried some IF statements, but they do not work either. Any other ideas? Is this even possible?Thanks.

Andy

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 8, 2011

    Sounds like a job for the group by attribute of the cfoutput tag.

    Inspiring
    April 8, 2011

    Dan,

         That's what I tried, but it only displays the first item row with the PNR Initials, but then the BOM initials have a drop down menu still in it and not the "AG" initials that are in the database already for that item. It basically deletes the 2nd row  or the 2nd item and only displays the first row of information. Do I need to run 2 different output queries with the group attribute? One for the PNR Initals column and one for the BOM initials column? I've tried this too, but the table gets really messed up and doesn't line up normal.

    Andy

    Inspiring
    April 8, 2011

    Here's what my code looks like for this table. Is there anything I can do since the code is being output dynamically?

    <table width=*% align="center" cellspacing="0" cellpadding="4" border="0">
    <tr>
        <td><B>ECO</B>   </td>
        <td><B>ECO ItemID</B>   </td>
        <td><B>APVID</B>   </td>
        <td><B>APV ItemID</B>   </td>
        <td><B>Part Number   </B></td>
        <td align="center"><B>PNR</B></td>
        <td align="center"><B>BOM</B></td>
        <td align="center"><B>Open Jobs Affected</B></td>
    </tr>

    <!---------------- OUTPUT Company SEARCH RESULTS ---------------->

    <cfform name="EditItem" method="post" action="Queue_PNR_BOM_action.cfm">

    <CFOUTPUT QUERY="PNRBOMSearch">


    <input type="hidden" name="ECID#ItemID#" value="#ECID#">
    <input type="hidden" name="ItemID#ItemID#" value="#ItemID#">
    <input type="hidden" name="PNR_Doc_Type#ItemID#" value="PNR Req">
    <input type="hidden" name="BOM_Doc_Type#ItemID#" value="BOM Req">


    <tr>
        <td>
        <cfif ECID is not "">
        <a href="item_display.cfm?ECID=#ECID#">#ECID#</a>
        <cfelse>
          </cfif></td>
       
        <td width="auto">
        <cfif ItemID Is Not "">
        #ItemID#
        <cfelse>
          </cfif></td>
       
        <td width="auto">
        <cfif APVID Is Not "">
        #APVID#
        <cfelse>
          </cfif></td>
       
        <td width="auto">
        <cfif APV_ItemID Is Not "">
        #APV_ItemID#
        <cfelse>
          </cfif></td>
       
        <td width="auto">
        <cfif Part_Number Is Not "">
        #Part_Number#
        <cfelse>
          </cfif></td>

    <td align="center">
    <cfif Approval_Initials Is Not "" and Document_Type EQ "PNR Req">
    #Approval_Initials#
    <cfelse>

    <select name="PNR_Approval_Initials#ItemID#">
    <option value="">Select Initials</option>
    <cfloop query="ShowInitials">
    <cfif Engineer_Initials EQ 1>
    <option value="#Initials#">#Initials#</option>
    </cfif>
    </cfloop>
    </select>
    </cfif>
    </td>

    <td align="center">
    <cfif Approval_Initials Is Not "" and Document_Type EQ "BOM Req">
    #Approval_Initials#
    <cfelse>

    <select name="BOM_Approval_Initials#ItemID#">
    <option value="">Select Initials</option>
    <cfloop query="ShowInitials">
    <cfif Engineer_Initials EQ 1>
    <option value="#Initials#">#Initials#</option>
    </cfif>
    </cfloop>
    </select>
    </cfif>
    </td>
       
    <!--- <td>
    <select name="BOM_Approval_Initials#ItemID#">
    <option value="">Select Initials</option>
    <cfloop query="ShowInitials">
    <cfif Engineer_Initials EQ 1>
    <option value="#Initials#"
    <cfif #Initials# EQ #PNRBOMSearch.Approval_Initials#>selected</cfif>>#Initials#</option>
    </cfif>
    </cfloop>
    </select>
    </td> --->


    <td><input name="Open_Jobs_Affected#ItemID#" type="text" value="#Trim(Open_Jobs_Affected)#" size="30"></td>

    </tr>

    <!--- </CFLOOP> --->
    </cfoutput>

    <tr>
    <td>
     
    </td>
    </tr>

    <tr>
    <td colspan="4" align="center">

    <input type="submit" value="Update"> 
    <input type="reset" value="Reset"></td>
    </tr>

    </table>


    <cfoutput>
         <input type="hidden" name="listofids" value="#ValueList(PNRBOMSearch.ItemID)#">
         <!--- <input type="hidden" name="listofapvids" value="#ValueList(PNRBOMSearch.APV_ItemID)#"> --->
    </cfoutput>

    </cfform>

    Andy