Solved

Coldfusion Limit result from array

Posted on 2004-10-13
5
338 Views
Last Modified: 2013-12-20
I just want to grab the first FLTDURATION from array Arr_TotalResults. The following gives me a FLTDURATION for every item in the array. Is there a simple way to limit the result to just the first 'FLTDURATION' ?

<cfloop from="1" to="#arraylen(Arr_TotalResults)#" index="i"><cfoutput>(#Arr_TotalResults[i].FLTDURATION#)</cfoutput></cfloop>

Many thanks,
Michelle
0
Comment
Question by:mjacobs2929
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:kkhipple
ID: 12297173
<CFOUTPUT>
     #Arr_TotalResults[1]#
</CFOUTPUT>


This should give you the first value of the array. Now if FLT_DURATION is the first element, then this works. If FTL_DURATION is the fourth element in the array, then this works:

<CFOUTPUT>
     #Arr_TotalResults[4]#
</CFOUTPUT>


REFERENCE: http://livedocs.macromedia.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/arrayStruct3.htm
0
 

Author Comment

by:mjacobs2929
ID: 12297983
Sorry, this is actually an array of a structure, so I can't rely on 'FLTDURATION' always being at position 4, or whatever. Is it possible to get just the first occurance of 'FLTDURATION' from an array containing a structure?
0
 
LVL 10

Accepted Solution

by:
Mause earned 500 total points
ID: 12299580
Hi

Width your code you loop over the array and get every FLTDURATION but this is not what you want!

To get the FLTDURATION of the first array position you do this:
<cfoutput>(#Arr_TotalResults[1].FLTDURATION#)</cfoutput>

Will this work for you?
or does every array value contains a different structure and you want the first FLTDURATION that is found in the array?

Let me know
Mause
0
 

Author Comment

by:mjacobs2929
ID: 12299646
Yep, that worked! Just wanted the first instance. I guess that shows how little I understand CF arrays or structures! :[
0
 
LVL 10

Expert Comment

by:Mause
ID: 12299654
NP

Glad I could help
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WEB Service vs ??? 7 107
AD LDS, AD FS, RODC, LDAP access for 3rd party vendors? 5 87
Redundant SQL Servers Without Clustering 7 92
System Analysis 5 51
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now