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

sorting displaying issue

New Here ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

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>

Views

397

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
community guidelines
Community Expert ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

LATEST

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>

Votes

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
community guidelines
Resources
Documentation