Skip to main content
Participant
Oct 26, 2018 7:55 PM UTC
Question

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

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

This topic is closed to new replies. Start a new post to keep the conversation going.

8 replies

Participant
Oct 29, 2018 4:20 PM UTC

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.

Translate
BKBK
Community Expert
Community Expert
Oct 29, 2018 8:58 PM UTC

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
WolfShade
Legend
Oct 30, 2018 12:54 PM UTC

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

V/r,

^ _ ^

Translate
WolfShade
Legend
Oct 26, 2018 8:37 PM UTC

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
Participant
Oct 27, 2018 3:43 AM UTC

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
BKBK
Community Expert
Community Expert
Oct 27, 2018 2:11 PM UTC

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

Translate