Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Skipping the first tD while displaying the query result with a loop in a table

Community Beginner ,
Oct 26, 2018 Oct 26, 2018
I have a query getNamesandRoles that will display the result as such
    DISPLAYNAME   JOBROLE

    X                          X does someting

    Y                          Y does someting

    Z                          Z does someting

I want to display the result of this query in a table which is shown below, I can get to show the results with a loop or through explicitly calling the query as getNamesandRoles.displayName[1] and so on, but I can figure out how to loop thru the query in a way that would skip the first row where the ID (i.e. all the scope="row") and populate the data in the other two Td's dynamically so that it we have more users it creates those TD's related to the ID. Can i accomplish this ?

table.JPG
<table class="table table-bordered">

   <thead>

   <tr>

   <th scope="col">SomeroleID</th>

   <th scope="col">First</th>

   <th scope="col">Last</th>

  

   </tr>

   </thead>

   <tbody>

   <tr>

   <th scope="row">RoleFunction</th>

   <td>X</td>

   <td>X does someting</td>

  

   </tr>

   <tr>

   <th scope="row">RoleFunction1</th>

   <td>Y</td>

   <td>Y does someting </td>

  

   </tr>

   <tr>

   <th scope="row">RoleFunction</th>

   <td>z</td>

   <td>Z does someting  </td>

  

   </tr>

   </tbody>

   </table>

685
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 26, 2018 Oct 26, 2018

I'm not sure I understand your question.  Is this what you're looking for?

<table class="table table-bordered">
  <thead>
  <tr>
  <th scope="col">SomeroleID</th>
  <th scope="col">First</th>
  <th scope="col">Last</th>
  </tr>
  </thead>

  <tbody>
<cfoutput query="queryName">
  <tr>
  <th scope="row">RoleFunction</th>
  <td>#queryName.colA#</td>
  <td>#queryName.colB#</td>
  </tr>
</cfoutput>
  </tbody>
</table>

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 26, 2018 Oct 26, 2018

No, that is not what i was looking for. I guess my question is about looping through the query and appending the values sequentially in dynamically created TD's for Some header, Some other header , and Something else entirely. Some way to populate a table but skipping the first TD.

<table class="table table-bordered">

   <thead>

   <tr>

   <th scope="col">SomeroleID</th>

   <th scope="col">First</th>

   <th scope="col">Last</th>

 

   </tr>

   </thead>

   <tbody>

   <tr>

   <th scope="row">Some header </th>

   <td>X</td>

   <td>X does someting</td>

 

   </tr>

   <tr>

   <th scope="row">Some other header </th>

   <td>Y</td>

   <td>Y does someting </td>

 

   </tr>

   <tr>

   <th scope="row">Something else entirely</th>

   <td>z</td>

   <td>Z does someting  </td>

 

   </tr>

   </tbody>

   </table>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2018 Oct 27, 2018

Hi Userfromcoloroado​, I have read your question a number of times. I still don't understand what you're asking.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2018 Oct 27, 2018

I agree, which is why I have not chimed in. It seems like you need to add at least a few more lines to demonstrate the variability you keep referring to.


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 29, 2018 Oct 29, 2018

Apologies about being unclear.

DATA from Query getNamesandRoles

DISPLAYNAME   JOBROLE

    X                          X does someting

    Y                          Y does someting

    Z                          Z does someting

I  want to populate the data in the format of the expected table with a loop so that the <td> for the headers are skipped but we can poplate displayname and Job role.

Thank you.

table.JPG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2018 Oct 29, 2018

Assuming the column names are roleFunction, displayName and jobRole, then you perhaps want something like

<table class="table table-bordered">

   <thead>

   <tr>

   <th scope="col">Role ID</th>

   <th scope="col">Name</th>

   <th scope="col">Role</th>

   </tr>

   </thead>

   <tbody>

   <cfoutput query="getNamesandRoles">

   <tr>

   <th scope="row">#getNamesandRoles.roleFunction#</th>

   <td>#getNamesandRoles.displayName#</td>

   <td>#getNamesandRoles.jobRole#</td>

   </tr>

   </cfoutput>

   </tbody>

</table>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 30, 2018 Oct 30, 2018

Essentially the same thing I suggested.  OP indicated negatory.  (shrug)

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 31, 2018 Oct 31, 2018
LATEST

The only other thing that I can think of is that the OP is looping within the TR, which doesn't make any sense, to me.

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources