Cold Fusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingCold Fusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 7th, 2005, 11:09 PM
dex002 dex002 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 dex002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 12 sec
Reputation Power: 0
looping to create a struct

Hi, I am trying to build a struct dynamically. The number of rows my query returns changes all the time, so the contents of my struct will grow or shrink accordingly. How do I get the struct indexes to change dynamically?

You can see below that I need to dynamically change the value of structIndex based on the recordcount, whilst at the same time filling the struct with every record, not just one of them.

I'm sorry if this isn't making much sense, its hard to explain. Please help if you can!

Code:
<cfloop query = "getGigsFlash">

<cfset tempStruct = StructNew()>
<cfset tempStruct.gig_id[structIndex] = getGigsFlash.gig_id[structIndex]>
<cfset tempStruct.gig[structIndex] = getGigsFlash.gig[structIndex]>
<cfset tempStruct.gig_date[structIndex] = getGigsFlash.fgig_date[structIndex]>
<cfset tempStruct.venue[structIndex] = getGigsFlash.venue[structIndex]>
<cfset tempStruct.address[structIndex] = getGigsFlash.address[structIndex]>
<cfset tempStruct.time[structIndex] = getGigsFlash.time[structIndex]>
<cfset tempStruct.phone[structIndex] = getGigsFlash.phone[structIndex]>
<cfset tempStruct.cost[structIndex] = getGigsFlash.cost[structIndex]
<cfset tempStruct.highlight[structIndex] = getGigsFlash.highlight[structIndex]>

</cfloop>

Reply With Quote
  #2  
Old August 8th, 2005, 01:37 AM
dex002 dex002 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 2 dex002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 12 sec
Reputation Power: 0
Ok, I found the answer on another site. Here's how it works:

Code:
<cfset gigArray = arrayNew(1)>

<cfloop query="getGigsFlash">

<cfset gigArray[arrayLen(gigArray) + 1] = structNew()>
<cfset gigArray[arrayLen(gigArray)].gig_id = getGigsFlash.gig_id>
<cfset gigArray[arrayLen(gigArray)].gig = getGigsFlash.gig>
<cfset gigArray[arrayLen(gigArray)].venue = getGigsFlash.venue>
<cfset gigArray[arrayLen(gigArray)].address = getGigsFlash.address>
<cfset gigArray[arrayLen(gigArray)].time = getGigsFlash.time>
<cfset gigArray[arrayLen(gigArray)].phone = getGigsFlash.phone>
<cfset gigArray[arrayLen(gigArray)].cost = getGigsFlash.cost>
<cfset gigArray[arrayLen(gigArray)].highlight = getGigsFlash.highlight>
<cfset gigArray[arrayLen(gigArray)].fgig_date = getGigsFlash.fgig_date>

</cfloop>

		<cfreturn gigArray>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > looping to create a struct


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap