Highlighted

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

Community Beginner ,
Oct 26, 2018

Copy link to clipboard

Copied

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>

Views

272

Likes

Translate

Translate

Report

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

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

Community Beginner ,
Oct 26, 2018

Copy link to clipboard

Copied

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>

Views

273

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2018 0
Community Beginner ,
Oct 26, 2018

Copy link to clipboard

Copied

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2018 0
Adobe Community Professional ,
Oct 27, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 27, 2018 0
Adobe Community Professional ,
Oct 27, 2018

Copy link to clipboard

Copied

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 (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 27, 2018 0
Community Beginner ,
Oct 29, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 29, 2018 0
Adobe Community Professional ,
Oct 29, 2018

Copy link to clipboard

Copied

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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 29, 2018 0
LEGEND ,
Oct 30, 2018

Copy link to clipboard

Copied

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

V/r,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 30, 2018 0
LEGEND ,
Oct 31, 2018

Copy link to clipboard

Copied

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,

^ _ ^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 31, 2018 0