Skip to main content
Inspiring
October 26, 2008
Answered

Split a query result

  • October 26, 2008
  • 3 replies
  • 536 views
Hello

I would like to split/group (I'm not sure about terms) a query result. Let's assume I get a query with 50 results. I would like to show only 4 then the next 4 etc. I have the following code which displays active and inactive arrows.
I imagine building a loop around my result sets of 4 and place each of those sets in a DIV. The linked arrow images would then show resp. hide the DIVs.

Below the code I prepared so far but I cannot go on because can't resolve the question above and then find an efficient idea of showing each result set.

Has somebody a good input? Would be great!

Many thanks
    This topic has been closed for replies.
    Correct answer tomtomtom7147938
    Here the solution to my problem:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=3&threadid=1402501

    3 replies

    tomtomtom7147938AuthorCorrect answer
    Inspiring
    November 17, 2008
    Inspiring
    October 27, 2008
    Hi,

    Have a look at the startrow and maxrow attributes for the <cfoutput> tag: <cfoutput startrow="" maxrows="">
    They allow you to show only certain rows of a recordset.

    cheers,
    fober
    Inspiring
    October 26, 2008
    Here is how to put your query into divs, 4 records at a time

    <cfoutput query = "test">
    <div>
    #data#
    <cfif currentrow is recordcount>
    </div>
    <cfesleif currentrow mod 4 is 0>
    </div><div>
    </cfif>

    To show and hide divs, google "javascript show hide <div>"

    I anticipate a problem with positioning on the screen. Beyond my level of expertise to solve stuff like that.
    Inspiring
    October 29, 2008
    Hello

    Thank you very much for your inputs. I went on with Dan's idea 'modulo'. And I am unfortunately stuck with a detail... Let's change the initial parameters: Assume we have a query with 9 results and I would like to build DIVs containing 2 results each. Every DIV is set to 'display: none;', so nothing is displayed on a page for the moment!

    At the very bottom of the page I place back and forward arrows in DIVs to navigate through the DIVs above. I managed to build the sets of DIVs an giving them an ID (see code). Every ID appears twice, once in the DIV containg the 2 results and once in the DIV containing the navigation arrows. Because I want to display the arrows depending on where I am staying in navigation. Means, when I display the first DIV there is no option to go backwards, so the back arrow is inactive. If you go one step forward you can navigate backwards and forwards so both arrows have to be active. AND NOW MY PROBLEM: At the very end you cannot navigate forward any longer so I would like to display a forward button which I inactive (and a backwards button which is active).

    The whole displaying will be controled by JavaScript.

    Do you have a good idea for this ending condition issue? Many thanks!