Hi all
I have an array and need to output the data in it into a table.
Each row will have five columns and then create a new row if necessary to continue outputting the contents of the array. The layout will look something like this:
Sports Mens Womens Kids Toys
Health Beauty Phones Gaming…
I have no idea how to get this to work. Any suggestions would be great.
Thanks
Phil
system
June 24, 2010, 5:42pm
2
I guess PhilJ2008 has no comment too
I am in no position to prove OR disprove that statement at this given time.
system
June 24, 2010, 11:43am
4
If you say so All I saw was only extracting one field. Yet not being able to use a SQL distinct for some reason … ? I dunno
system
June 23, 2010, 12:59pm
5
I didn’t have time to read the whole thing in detail. It sounded like he just needed distinct names, which a QoQ could do easily. But I may have missed something
But right now duty beckons. So I’ll have to review it later.
He had some issues with Distinct as well
<cfset name = " " />
<cfif recNum lte arrayLen(cleanArray)>
<cfset name = cleanArray[recNum] />
</cfif>
<td class=“catList”><a href=“categories3.cfm?table=#URL.table#&searchItem=#name#”>#name#</a></td>
Well ok that bit isn’t my code
http://www.cfdeveloper.co.uk/forum/forum_posts.asp?TID=696&PN=0&TPN=1
Have a look at that cfdeveloper.co.uk link on my last point… we went through those options, apart from the QoQ.
Phil mentioned that he’d converted to an array just before this code to remove some duplicates so that’s the reason behind this approach.
Nice bit of coding there Phil
Hi All
Worked out the issue and here is the code for what I did, in case someone else needs it at a later stage.
<cfset noPerRow = 3 />
<cfset start = 1 />
<cfset finish = noPerRow />
<cfoutput>
<table>
<cfloop condition="start lte arrayLen(cleanArray)">
<tr>
<cfloop from="#start#" to="#finish#" index="recNum">
<cfset name = " " />
<cfif recNum lte arrayLen(cleanArray)>
<cfset name = cleanArray[recNum] />
</cfif>
<td class="catList"><a href="categories3.cfm?table=#URL.table#&searchItem=#name#">#name#</a></td>
</cfloop>
<cfset start = finish+1 />
<cfset finish += noPerRow />
</tr>
</cfloop>
</table>
</cfoutput>
system
June 23, 2010, 9:32am
11
<cfset name = " " />
<cfif recNum lte arrayLen(cleanArray)>
<cfset name = cleanArray[recNum] />
</cfif>
<td class="catList"><a href="categories3.cfm?table=#URL.table#&searchItem=#name#">#name#</a></td>
Good job figuring things out. One small suggestion. Move the link inside the CFIF so you don’t generate an empty link.
<cfif recNum lte arrayLen(cleanArray)>
<cfset name = cleanArray[recNum] />
<td class="catList"><a href="categories3.cfm?table=#URL.table#&searchItem=#name#">#name#</a></td>
</cfif>
system
June 23, 2010, 12:05pm
12
Oooh… now I understand Clarkee21’s wink
BTW: Do you really need arrays for this? Can’t you just do a QoQ or maybe cfoutput’s group attribute …?
LOL
Its good to share… hehehe