3 Replies Latest reply on Apr 3, 2007 9:03 AM by Dan Bracuk

    using a loop

    TESS_GEAR Level 1
      please help me this code to use a loop instead of cfif series. thank you!
        • 1. Re: using a loop
          jdeline Level 1
          Check out the code below.
          • 2. Re: using a loop
            Level 7
            how to "loop" it depends on what "process" you intend to "do"...
            if all "processes" are same except for each uses a different tabshow
            value, you can loop it (e.g. looping from=149 to=144 using step="-1" in
            your loop and <cfbreak> to break out of if a query inside the loop
            returns any records); if not... maybe a generic code like below can work
            for you:

            <cfquery name="getqry1">
            select test from testtable where tabshow = 149
            <cfif getqry1.recordcount gt 0>
            <cfoutput query="getqry1">
            do your process 1

            <cfquery name="getqry2">
            select test from testtable where tabshow = 148
            <cfif getqry2.recordcount gt 0>
            <cfoutput query="getqry2">
            do your process 2

            and so on...

            whether this works or not depends a lot on other code in your page, i.e.
            <cfabort> will stop ALL processing, including any cfml/html code outside
            this structure...


            Azadi Saryev
            • 3. Re: using a loop
              Dan Bracuk Level 5
              select test
              from testtable
              where tabshow between 144 and 149
              order by tabshow desc

              Think you can take it from there?