Looping through a query in cfscript

2003-11-15 Thread Ryan Mitchell
Hello

I need to loop over a query in cfscript.
I notice when I cfdump the query there is a record number in the left hand
column, how would I loop using this as the identifier? I usually use cfloop
but this is in the middle of a cfscript block :)

Thanks,
Ryan

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Looping through a query in cfscript

2003-11-15 Thread Philip Arnold
myQuery.myColumn[recordNumber]

 
Or

 
myQuery[myColumnVar][recordNumber]

-Original Message-
From: Ryan Mitchell [mailto:[EMAIL PROTECTED] 
Sent: Saturday, November 15, 2003 1:43 PM
To: CF-Talk
Subject: Looping through a query in cfscript

Hello

I need to loop over a query in cfscript.
I notice when I cfdump the query there is a record number in the left
hand
column, how would I loop using this as the identifier? I usually use
cfloop
but this is in the middle of a cfscript block :)

Thanks,
Ryan

_


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Looping through a query in cfscript

2003-11-15 Thread Ben Doom
What I've always done is loop through the query like a structure of arrays:

for (i = 1; i = query.recordcount; i = i + 1)
{
	do_something_with(query.column[i]);
}

HTH.

--Ben Doom

Ryan Mitchell wrote:

 Hello
 
 I need to loop over a query in cfscript.
 I notice when I cfdump the query there is a record number in the left hand
 column, how would I loop using this as the identifier? I usually use cfloop
 but this is in the middle of a cfscript block :)
 
 Thanks,
 Ryan
 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: Looping through a query in cfscript

2003-11-15 Thread Ryan Mitchell
Thanks :)
Spot on

On 15/11/03 6:55 pm, Ben Doom [EMAIL PROTECTED] wrote:

 What I've always done is loop through the query like a structure of arrays:
 
 for (i = 1; i = query.recordcount; i = i + 1)
 {
 do_something_with(query.column[i]);
 }
 
 HTH.
 
 --Ben Doom
 
 Ryan Mitchell wrote:
 
  Hello
  
  I need to loop over a query in cfscript.
  I notice when I cfdump the query there is a record number in the left hand
  column, how would I loop using this as the identifier? I usually use cfloop
  but this is in the middle of a cfscript block :)
  
  Thanks,
  Ryan
  
 
 
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Looping through a Query in CFSCRIPT

2001-04-03 Thread Jason Lees (National Express)


Hi all,

Is it possible to loop through the results of a CFQuery structure? 

and Has anybody got an example of how its done

TIA.


Jason Lees 
National Express
Email : [EMAIL PROTECTED]

###
This document is intended for, and should only be read by, those persons to
whom it is addressed. Its contents are confidential and if you have received
this message in error, please notify us immediately by telephone on 0121 609 6301
and delete all records of the message from your computer. Any form of reproduction,
dissemination, copying, disclosure, modification, distribution and / or
publication of this message without our prior written consent is strictly
prohibited. Neither the author of this message nor their employers accept
legal responsibility for the contents of the message. Any views or opinions
presented are solely those of the author.
If you have any queries please contact [EMAIL PROTECTED]

##


~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Looping through a Query in CFSCRIPT

2001-04-03 Thread Dain Anderson

Jason,

You could use something like this:

 code ...
cfscript
for (i = 1; i LTE myQuery.RecordCount; i = i + 1) {
  WriteOutput("
  tr
td#myQuery.Column1[i]#/td
td#myQuery.Column2[i]#/td
td#myQuery.Column3[i])#/td
td#myQuery.Column4[i])#/td
  /tr
  ");
}
/cfscript
 code ...

Where "myQuery" is your query name and "Column" represents a column name.

Dain Anderson
Caretaker, CF Comet
http://www.cfcomet.com/


- Original Message -
From: "Jason Lees (National Express)" [EMAIL PROTECTED]
To: "CF-Talk" [EMAIL PROTECTED]
Sent: Tuesday, April 03, 2001 10:54 AM
Subject: Looping through a Query in CFSCRIPT



 Hi all,

 Is it possible to loop through the results of a CFQuery structure?

 and Has anybody got an example of how its done

 TIA.


 Jason Lees
 National Express
 Email : [EMAIL PROTECTED]

 ###
 This document is intended for, and should only be read by, those persons
to
 whom it is addressed. Its contents are confidential and if you have
received
 this message in error, please notify us immediately by telephone on 0121
609 6301
 and delete all records of the message from your computer. Any form of
reproduction,
 dissemination, copying, disclosure, modification, distribution and / or
 publication of this message without our prior written consent is strictly
 prohibited. Neither the author of this message nor their employers accept
 legal responsibility for the contents of the message. Any views or
opinions
 presented are solely those of the author.
 If you have any queries please contact [EMAIL PROTECTED]
 
 ##



~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Looping through a Query in CFSCRIPT

2001-04-03 Thread Joe Sheble aka Wizaerd

Here's an example:
CFQUERY NAME="qTest" DATASOURCE="#DSN_Name#" USERNAME="#DSN_Username#" 
PASSWORD="#DSN_Password#"
 SELECT ID, Option_Desc
 FROM Forecast.dbo.Options
 ORDER BY ID
/CFQUERY

CFSCRIPT
for( x = 1; x LTE qTest.RecordCount; x=x+1 ) {
 WriteOutput( qTest.ID[x]  " - "  qTest.Option_Desc[x]  "br" );
}
/CFSCRIPT


At 03:54 PM 4/3/01 +0100, Jason  Lees (National Express) wrote:

Hi all,

Is it possible to loop through the results of a CFQuery structure?

and Has anybody got an example of how its done

TIA.


Jason Lees
National Express
Email : [EMAIL PROTECTED]

###
This document is intended for, and should only be read by, those persons to
whom it is addressed. Its contents are confidential and if you have received
this message in error, please notify us immediately by telephone on 0121 
609 6301
and delete all records of the message from your computer. Any form of 
reproduction,
dissemination, copying, disclosure, modification, distribution and / or
publication of this message without our prior written consent is strictly
prohibited. Neither the author of this message nor their employers accept
legal responsibility for the contents of the message. Any views or opinions
presented are solely those of the author.
If you have any queries please contact [EMAIL PROTECTED]

##



~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Looping through a Query in CFSCRIPT

2001-04-03 Thread Jason Lees (National Express)


Thanks for all the help, I've tried the solution and it works, I forgot that
effectivly the query is a structured array.

I need a break/holiday or caffine injection.

Jason Lees 
National Express
Email : [EMAIL PROTECTED]


-Original Message-
From: Hayes, David [mailto:[EMAIL PROTECTED]]
Sent: 03 April 2001 16:19
To: CF-Talk
Subject: RE: Looping through a Query in CFSCRIPT


CFSCRIPT
for(myCounter=1;
myCounter LTE myQuery.recordcount;
myCounter = myCounter + 1){
writeOutput(myQuery.myFieldName[myCounter]  'br');
};

/CFSCRIPT

-Original Message-
From: Jason Lees (National Express)
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 03, 2001 9:55 AM
To: CF-Talk
Subject: Looping through a Query in CFSCRIPT



Hi all,

Is it possible to loop through the results of a CFQuery structure? 

and Has anybody got an example of how its done

TIA.


Jason Lees 
National Express
Email : [EMAIL PROTECTED]

###
This document is intended for, and should only be read by, those persons to
whom it is addressed. Its contents are confidential and if you have received
this message in error, please notify us immediately by telephone on 0121 609
6301
and delete all records of the message from your computer. Any form of
reproduction,
dissemination, copying, disclosure, modification, distribution and / or
publication of this message without our prior written consent is strictly
prohibited. Neither the author of this message nor their employers accept
legal responsibility for the contents of the message. Any views or opinions
presented are solely those of the author.
If you have any queries please contact [EMAIL PROTECTED]

##
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists