1 Reply Latest reply on May 15, 2013 1:26 PM by BKBK

    sorting displaying issue

    NewTwoCF

      I am trying to display a list sorted by year, then title and then subtitle. if there are no subtitles, titles should appear by itself. if there are subtitles then they should appear under titles, all in alph order.

       

      Here is a pic of what i am trying to get: http://www.flickr.com/photos/irfanirfan/8740957103/

      Here is the code I have so far, any poniters would be helpful.

       

      <cfquery name="getYear" DATASOURCE="LibDB" DBTYPE="ODBC">

      SELECT distinct Year

      FROM Everything

      WHERE deleteflag = 0

      ORDER by Year DESC

      </cfquery>

      <cfoutput>

      <cfloop query="getYear">

        <br><a onClick="Toggle('#getYear.Year#')" class="toggle" style="border-top: 0px;" onMouseOver="this.style.cursor='pointer';">

         <b>#getYear.Year#</b></a><span id="toggle#getYear.Year#" style="display: true"><img src='images/max.gif' alt='Maximize' border=0></span><br>

        <div id="div#getYear.Year#" style="display: none;" class="toggle">

         <cfquery name="getTitle" DATASOURCE="LibDB" DBTYPE="ODBC">

          SELECT distinct Title

          FROM Everything

          WHERE deleteflag = 0 and Year = '#getYear.Year#'

          ORDER by Title

         </cfquery>

         <cfloop query="getTitle">

              <a onClick="Toggle('#getTitle.Title#')" class="toggle" style="border-top: 0px;" onMouseOver="this.style.cursor='pointer';">

          #getTitle.Title#</a><span id="toggle#getTitle.Title#" style="display: true"><img src='images/max.gif' alt='Maximize' border=0></span><br>

          <div id="div#getTitle.Title#" style="display: none;" class="toggle">

          <cfquery name="getAll" DATASOURCE="LibDB" DBTYPE="ODBC">

           SELECT *

           FROM Everything

           WHERE deleteflag = 0 and Year = '#getYear.Year#' and Title = '#getTitle.Title#'

           ORDER by Title, subTitle

          </cfquery>

          <cfloop query="getAll">

                   #subTitle#<br>

          </cfloop>

         </div>

         </cfloop>

        </div>

      </cfloop>

      </cfoutput>

        • 1. Re: sorting displaying issue
          BKBK Adobe Community Professional & MVP

          What about putting <span> after the last query, and adding an if-condition, like this:

           

          <cfloop query="getTitle">

              <a onClick="Toggle('#getTitle.Title#')" class="toggle" style="border-top: 0px;" onMouseOver="this.style.cursor='pointer';">#getTitle.Title#</a>

              <cfquery name="getAll" DATASOURCE="LibDB" DBTYPE="ODBC">

              SELECT *

              FROM Everything

              WHERE deleteflag = 0 and Year = '#getYear.Year#' and Title = '#getTitle.Title#'

              ORDER by Title, subTitle

              </cfquery>

             <cfif getAll.RecordCount NEQ 0>

                  <span id="toggle#getTitle.Title#" style="display: true"><img src='images/max.gif' alt='Maximize' border=0></span><br>

                  <div id="div#getTitle.Title#" style="display: none;" class="toggle">

                  <cfloop query="getAll">

                       #subTitle#<br>

                  </cfloop>

                  </div>

              </cfif>

          </cfloop>