Rearranging records with code

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Rearranging records with code

    I am working on a data driven application where I need to be able to rearrange
    the ordering of records through a Web interface. (Perhaps similar to how you
    rearrange movies in your queue at Netflix.com) There are about 200 records of
    eLearning content, and I would like a courseware designer to be able to
    rearrange what order the pages will be displayed by the Web application.

    Does anyone have any CF techniques that will enable me to do this easily?

    gmahler5th Guest

  2. Similar Questions and Discussions

    1. Why doesn't the Code Completion occur in FlexBuilder IDEwhen source code is in an external file?
      I am seperating my .as from the MXML by using the following in my file.mxml: <mx:Script source="file.as"> When I edit file.as, the code...
    2. Table of Contents - Problem rearranging styles within TOC
      Hmmm. This seems to have worked for the entire TOC except for one entry. No matter what I do, this one name puts itself on top of the title. If there...
    3. Rearranging XML fields before sending an xmlconnectorrequest?
      Hello there!, could anyone help me with this question? I want to use my XMLConnector to send an XML chain to a servlet. the Schema for this...
    4. Rearranging controls
      Hi, i am developing a user control that consists of different listboxes. The control needs the ability to arrange those listboxes in a different...
    5. Rearranging photos in Browser
      One can rename and renumber photos in Browser. But how do you rearrange them in Browser BEFORE numbering so that they are in the sequence you desire?
  3. #2

    Default Re: Rearranging records with code

    For example, I see a record at position 100 and I want this record to be put at
    position 90, and the previous record 90 to become 91, 91 to become 92, and so
    on, rearranging the remainder of the records by one position.

    I am thinking of some kind of loop, but not sure how to do the loop until the
    end of a recordset.

    gmahler5th Guest

  4. #3

    Default Re: Rearranging records with code

    to answer your question on this specific issues, if you had records that were
    ordered sequentially in the database in a column named order_number from 1-150,
    and you wanted to move record 100 to record 40, rather than a loop you would do
    something similar to this :

    <<attaching code>>

    -Nate Nielsen
    [url]http://www.webclarity.com[/url]

    <cfset currentOrderNumber = 100>
    <cfset newOrderNumber = 40>

    <cfquery datasource="yourDSN" name="qReorder">
    -- set the record we want to move to the zero position
    update sections set order_number = 0 where order_number =
    #currentOrderNumber#;

    -- set all records at [currentOrderNumber] or below to +1 the current value
    update sections set order_number = order_number + 1 where order_number >=
    #newOrderNumber#;

    -- set the record we want to move into position
    update sections set order_number = #newOrderNumber# where order_number = 0;
    </cfquery>

    NateNielsen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139