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

using a loop

New Here ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

please help me this code to use a loop instead of cfif series. thank you!
TOPICS
Advanced techniques

Views

239

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

correct answers 1 Correct answer

Deleted User
Apr 03, 2007 Apr 03, 2007
Check out the code below.

Votes

Translate

Translate
Guest
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

Check out the code below.

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
LEGEND ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

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
</cfquery>
<cfif getqry1.recordcount gt 0>
<cfoutput query="getqry1">
do your process 1
</cfoutput>
<cfabort>
</cfif>

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

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
Sabai-dee.com
http://www.sabai-dee.com

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
LEGEND ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

LATEST
select test
from testtable
where tabshow between 144 and 149
order by tabshow desc

Think you can take it from there?

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