1 Reply Latest reply on May 15, 2006 12:29 AM by Nightfall_Blue

    query results:every other record/row grey and white

    briankind
      Hello guys,
      query results:every other record/row grey and white
      how would you make every other record/rows a different color just like the forums color. Lightest grey and white?


      <cfquery name="Myqueryname"
      datasource="#Request.MainDSN#">
      SELECT
      CompanyID,
      CompanyName,
      Address,
      City,
      State,
      ZipCode,
      Comments
      FROM
      Company
      ORDER BY
      CompanyName ASC
      </cfquery>

      <html>
      <head>
      <title>CF TUTORIALS</title>
      <link rel="stylesheet" href="styles.css">
      </head>

      <body>

      <h1>All CO Listings</h1>

      <table>
      <tr>
      <td><b>ID</b></td>
      <td><b>Name</b></td>
      <td><b>Address</b></td>
      <td><b>City</b></td>
      <td><b>State</b></td>
      <td><b>ZIP Code</b></td>
      <td> </td>
      </tr>
      <cfoutput query="Myqueryname">
      <tr>
      <td>#CompanyID#</td>
      <td>#CompanyName#</td>
      <td>#Address#</td>
      <td>#City#</td>
      <td>#State#</td>
      <td>#ZipCode#</td>
      <td>
      <a href=" ALL Emps.cfm?CompanyID=#CompanyID#">ALL Emps</a>
      <a href=" AddCO Form.cfm">AddCO</a>
      <a href=" Editco.cfm?CompanyID=#CompanyID#">Editco</a>
      <a href="CoDeleteForm.cfm?CompanyID=#CompanyID#">Delete</a>
      </td>
      </tr>
      </cfoutput>
      </table>

      </body>
      </html>
        • 1. Re: query results:every other record/row grey and white
          Nightfall_Blue
          There is a cool tool in Coldfusion called MOD

          This basically calculates the remainder of the row number when divided.

          I interpreted its use to something like this, which has worked for me.

          <cfoutput query="qry_requestedlist" maxrows="30" startrow="1">
          <cfset EvenRow=#CurrentRow# +1>
          <cfif CurrentRow Mod 2 IS 1>
          <tr>
          <th class="grey" CurrentRow#</th>
          <cfelse>
          <th class="white">#CurrentRow#</th>
          <tr>

          </cfif>
          </cfoutput>

          I doubt this is precisely what you want but this is the sort of thing.